Reply to comment

Fun facts

I find DOCTYPEs very interesting (sad but true). In particular, I've always wondered what practical effect they have on browsers - since browsers will do their very best to render even horribly broken HTML, and implement their own deviations from W3C, will an incorrect DOCTYPE have any effect? And since IE has such an abstract understanding of what makes a healthy HTML document, how does it interpret dtds, if at all?

There is a fun fact about IE's behaviour as regards doctypes. Sure you can use an XML doctype before the XHTML doctype to force quirks mode in older IEs, or use a malformed doctype (or none at all). But get this. IE7+ will attempt to download the dtd from the location specified in the DOCTYPE every time. It doesn't even cache it, or actually do anything useful with it (god knows it doesn't respect it). This means that every time anybody using IE7+ loads any HTML page with a doctype, W3.org gets an HTTP request! But this is the punchline: W3's hosted dtds have some browser-sniffing going on on the back end for each incoming HTTP request - if it's a normal, healthy looking one it will simply HTTP respond with the .dtd file. But if it detects IE, it returns a single word: 'NO'. I think this is one of the most hilarious IE deficiencies ever.

A nice way to avoid that stupid (but inconsequential) behaviour and keep everyone happy is to use the HTML5 doctype. It's valid on pretty much any well-formed XHTML document, forward-compatible, produces correct behaviour in all modern browsers, and easier to remember too:

<!DOCTYPE html>

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <csharp>, <css>, <html>, <javascript>, <vb>, <vbnet>, <xml>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.