title: extract div as HTML including CSS classes
body: <p>I am trying to create a general function that will extract a div content (with nested elements) and save it locally in an HTML file.</p>
  
  <p>Basically I get the div innerHTML, wrap it in html/head/body tags and then save it:</p>
  
  <pre><code>function div2html() {
      var inner=document.getElementById("div2save").innerHTML;
      var html="&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;"+inner+"&lt;/body&gt;&lt;/html&gt;";
      saveTextAsFile("div2html.html", html);
  }
  </code></pre>
  
  <p>See a working version here: <a href="http://jsfiddle.net/fb6s763w/" rel="nofollow">jsfiddle</a></p>
  
  <p>However I am not sure how to handle classes. As you can see the class in the sample (bigbold) is not embedded in the new HTML. I need some way to get all the classes used in the div and then add them (or the computed styles ?) to the html I generate .. is this possible ? is there any other way around it ?</p>