tags:

views:

262

answers:

9

I am just curious about the doctype use in Google, Yahoo and Stackoverflow.

And I find that the above 3 sites use HTML4.01 doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >

Many people say that we should use XHTML1.0 doctype but the above 3 sites do not do so. Do you know why?

I would also like to know which doctype you'll use when writing webpages.

+1  A: 

that's because IE doesn't support XHTML and interpret it as HTML... so some designers choose to simply use HTML 4.01 instead, which is more uniformly supported across all browsers.

some reference: http://en.wikipedia.org/wiki/XHTML#Adoption

Most web browsers have mature support for all of the possible XHTML media types. The notable exception is Internet Explorer by Microsoft.

I often use HTML 4.01 just because if I use XHTML and knows that it is not really interpreted as XHTML on IE, that's it is weird to keep on using it.

動靜能量
"notable expection" hehehe
Here Be Wolves
and that's a really big exception. some stat says it is about 66% of market.
動靜能量
But most of them put it under 15% http://www.w3counter.com/globalstats.php http://www.w3schools.com/browsers/browsers_stats.asp http://blog.stackoverflow.com/2009/08/browsers-and-screen-size-on-stack-overflow/ (as little as 7% in SO)
voyager
+2  A: 

I am always using HTML 4 as well, simply because of the widest compatibility with minimum hassle. Also HTML 4 Strict is a must, instead of Transitional (which is only intended for legacy pages and not the entire web [which is where it is used, apparently, though]). There was a question on SO recently which dealed with the relative benefits and shortcomings of XHTML over HTML: At the end of the day, why choose XHTML over HTML?

Joey
A: 

Backwards compatibility is important for those sites. Not so much for Stackoverflow, but for Google and Yahoo.

Georg
+3  A: 

XHTML is a lot more strict than ordinary HTML, and therefore it is hard (or even impossible, depending on the framework you use to build it) to get it right. I've seen many web pages that claim to be XHTML and fail big time at it (silently serving their content as "text/html" so the page loads at all).

As long as the whole HTML generation process, I mean all of it, has not been abstracted away into a framework, I venture to say it is impossible to guarantee that the outcome of a web page generation process is valid XHTML. But - many popular languages in use today (the majority, I guess) build HTML directly, with all the error potential of humans who don't know the spec by heart, or just don't care if a <div> inside a <p> is valid or not.

Apart from that it has no apparent enormous advantages over HTML that would justify it's use, especially if all you want is "build a web page for the display in a browser".

HTML 4.01 is well supported among user agents and does a good job. Personally, I don't see a really good reason to move to XHTML. I don't say there are none, the topic is just a lot more academic than one might think.

Tomalak
A: 

I'd imagine it's a trade-off between standards-compliance and compatibility with (substantially) older browsers. So those 3 sites erred in favor of the latter. Also, some pages don't render properly unless you declare the correct doctype.

JC
A: 

XHTML is probably very difficult to get right if you are including the possibility of user generated content. One misplaced XML thing in the wrong place and the whole page will certainly fail to load.

1800 INFORMATION
This isn't a problem if you're using a library like HTML Purifier.
MiffTheFox
A: 

If you have access to analytics I would look at what browsers your audience use then pick the DOCTYPE you feel is most apropriate. If all your visitors are using IE3 you should probably go for some funky old HTML DOCTYPE.

Greg B
+6  A: 

I use the HTML5 doctype:

<!DOCTYPE html>

Because XHTML does not work on the web and doctype is essentially only good to trigger the standards layout mode, which the above construct does very well in every browser.

zoul
Ah XHTML is not working in the web, that's why most of the websites use it. And HTML5 is supported by very browser, even IE 5.5 and Netscape 4? I don't think so :)
Kau-Boy
+1  A: 

I use HTML 4.01 Strict for my personal projects. Gives me no worries about sending as application/xhtml+xml, it has full backward compatibility and it gives me those technical limits I want. I'm still a standards-geek, so my code is still clean even though the ML used doesn't require it (that much) from me.

To me, XHTML seems to have failed slightly. The next most-widely-used-standard in a few years time will probably be HTML5, since the entire XHTML2-project seems to have fallen behind.

I'm not saying it's bad to use it now, though. It's just so incredibly seldom you actually have an advantage by using XHTML instead of HTML. How many webpages based on XHTML today is doing it 100% correctly? Mostly they fail on the mime-type. text/html is allowed due to browser compatibility, but it's still wrong if you look at the entire reason XHTML exists. And how many does actually NEED the functionality XHTML brings?

I guess there are some, but the vast majority of XHTML-based webpages could just swap their doctype to a HTML 4.01 one and function just as well.

So until i can use XHTML (2?) the way it is supposed to (correct MIME-type basically) on all browsers, I just see no reason to use it over HTML 4.01 unless my application specifically needs the XML-integration. Even then I'd probably consider just doing all those modifications server-side, and go with HTML in the template.

Arve Systad