title: Append new attribute with setAttribute()?
body: <p>I have a div element and would like to append new style attributes to it.
  I have tried to do it like this:</p>
  
  <pre><code>element.setAttribute('style', 'property: value');
  </code></pre>
  
  <p>And it works, but if that element already had styles applied, they will all get overwritten.</p>
  
  <p>Lets say I have this situation:</p>
  
  <p>HTML: </p>
  
  <pre><code>&lt;div id="styled"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>var styled = document.getElementById('styled');
  styled.setAttribute('style', 'display: block');
  </code></pre>
  
  <p>This works, but if I need to append another style lets say:</p>
  
  <pre><code>styled.setAttribute('style', 'color: red');
  </code></pre>
  
  <p>I would then lose style added in previous setAttribute() method!</p>
  
  <p>How can one append styles to elements with JavaScript?</p>
  
  <p>Thanks!</p>