title: Curing HtmlTextWriter's Ugly Formatting?
body: <p>I'm creating an ASP.NET server control using the HtmlTextWriter class. My understanding is that it's a nice class to use for making sure my output HTML is valid. I assumed it would format things nicely as well, but it does a bunch of strange stuff that makes the output hard to read.</p>
  
  <p>Are there some settings or something I can play with to get this looking like someone took the time to properly format it, or is it just a downside of using this class? Here are some examples of the ugly formatting I'm talking about:</p>
  
  <ul>
  <li>Inconsistent use of self-closing tags. With some tags I get them, and others I don't.</li>
  <li>Random newlines between tags.</li>
  <li>Lack of newlines in appropriate places.</li>
  <li>Mismatched indentation.</li>
  </ul>
  
  <p>This is actually what I'm trying to reproduce:</p>
  
  <pre><code>&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="MySWF" width="100" height="100" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"&gt;
      &lt;param name="movie" value="/MySWF.swf"&gt;&lt;/param&gt;
      &lt;param name="quality" value="high" /&gt;
      &lt;param name="allowScriptAccess" value="sameDomain" /&gt; 
      &lt;embed align="middle" pluginspage="https://www.adobe.com/go/getflashplayer" width="100" quality="high" height="100" loop="false" name="MySWF" type="application/x-shockwave-flash" play="true" allowscriptaccess="sameDomain" src="/MySWF.swf" /&gt;
  &lt;/object&gt;
  </code></pre>
  
  <p>...and this is what I'm getting:</p>
  
  <pre><code>    &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="MySWF" width="100" height="100" codebase="https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"&gt;
          &lt;param name="movie" value="/MySWF.swf"&gt;
  
          &lt;/param&gt;&lt;param name="quality" value="high"&gt;
  
          &lt;/param&gt;&lt;param name="allowScriptAccess" value="sameDomain"&gt;
  
          &lt;/param&gt;&lt;embed align="middle" pluginspage="https://www.adobe.com/go/getflashplayer" width="100" quality="high" height="100" loop="false" name="MySWF" type="application/x-shockwave-flash" play="true" allowscriptaccess="sameDomain" src="/MySWF.swf" /&gt;
  &lt;/object&gt;
  </code></pre>