Since ASP.NET controls output HTML, is there a particular Doctype that works better with the kind of HTML they're likely to output? Are some Doctypes more flexible than others for this kind of usage?

I'm using C# on the server-side, if that's relevant.

5 answers

danwellman 5600

You need to use XHTML when using .net because of the attributes it adds to certain elements. Use XHTML doctype in order to validate

Answered almost 10 years ago by danwellman
  • ASP.NET controls are no where close to spitting decent HTML, so you are better off using danwellman's suggestion. I use XHTML transitional. Divya Manian almost 10 years ago
George 68

When a new .aspx page is created in Visual Studio it includes the xhtml 1.0 transitional doctype by default. I would stick to that unless you'd rather go with xhtml 1.0 strict.

Answered almost 10 years ago by George

Doctype depends on features you want in HTML.

I use HTML 4.01 strict, but that's just my preference. There is no "optimum".

Answered almost 10 years ago by Nathan DeGruchy
Brian 10


<!DOCTYPE html>
Answered almost 10 years ago by Brian
  • don't use HTML 5 as it is experimental and only has the most rudimentary browser support. Chris Sobolewski almost 10 years ago
  • Chris is wrong, you can write a site perfectly in HTML5 for IE6 and above: I've done it myself for clients. orta almost 10 years ago
  • <a href="">Support is spotty at best</a>. If you don't intend to use any of the features of HTML 5, then I suppose you're fine FOR NOW. However, when HTML becomes standard, if you are using any of the changed tags while declaring the HTML 5 doctype, there can be issues : If you use any of the depreciciated elements, there will definately be issues once HTML 5 becomes standard. Chris Sobolewski almost 10 years ago
  • I think the question relates specifically to ASP.NET, which has 'controls' that spit out a particular type of HTML. I wouldn't have thought they'd be HTML5 compliant, but I'm not sure. Matthew Brindley almost 10 years ago
Chad 0

By default, outputs html that is xhtml transitional compliant. You can adjust this by changing a setting in the web.config.

    <xhtmlConformance mode="Strict" />

For instance will make spit out xhtml strict code.

Answered almost 10 years ago by Chad