Which DTD to use? (HTML vs. XHTML)

They have: 68 posts

Joined: Dec 2005

Hi

What DTD is it best practice to use? What are the advantages or limitations and what is the one you use? I know i can use:

none
HTML 4.01 Transitional
HTML 4.01 Strict
XHTML 1.0 Transitional
XHTML 10.0 Strict
XHTML 1.1
XHTML Mobile 1.0

Im reviewing my current design practice and want to be using best practice for my customers.

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

OOh, good question! There are a lot of opinions out there about this - even the experts can't agree.

First of all, it's always best to use a strict doctype if possible. This means that the browsers won't go into "quirks mode" and you'll get a more reliable display. I personally prefer to have a Strict doctype with a few errors than a Transitional doctype with no errors. If it comes down to that - I don't usually find it that hard to get things to validate strict.*

So that baiscally brings you down to HTML 4.01 Streict or xHTML 1.0 Strict. The problem with xHTML (and particularly xHTML 1.1), is the fundamental difference between HTML and xHTML and how the browsers serve them. Some browsers (IE basically) can't serve xHTML as xHTML, they serve it as HTML. Someone else could explain this better than me. There is some information on the Mozilla Developer's FAQ.

Anyway, some people think that it's a problem to serve xHTML as HTML and will therefore use HTML 4.01 Strict rather than XHTML 1.0 Strict. There is a lot of discussion out there about this.

xHTML 1.1 is not an option because browsers can't handle it correctly. It is also a misconception that xHTML 1.1 is the next version following 1.0. It's not.

* I'm not one who believes that validation is necessarily the most important thing. Mistakes happen. Just in case someone goes to my site and tries to validate it Wink More on that here and here.

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Forgot to add: I personally use xHTML 1.0 strict. Firstly because I'm not convinced that the HTML/xHTML thing is really a problem (more because I haven't researched it that thoroughly, not because I understand all the different sides of the argument). xHTML is also stricter than HTML 4.01 strict so you can't get away with as much Smiling

They have: 68 posts

Joined: Dec 2005

I have received this in response to a question i asjked elsewhere:

"My recommendation would be HTML 4.01 Strict.

Why HTML and not XHTML? Because XHTML is useless as long as IE doesn't support it. You can only fake XHTML, and that may be 'harmful' if you don't know what you're doing.

Why Strict? Because it promotes separation between content (HTML), presentation (CSS) and behaviour (JavaScript), which is a good practice to learn."

Think i might go for HTML 4.01 Strict from now on if this is correct. Im not sure i understand the point here though. Presumably IE has a problem with xhtml?

I currently use this one as default with my web editor:

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

That is from one of those people who thinks it's a problem (or pointless) to serve xHTML to browsers that don't support it. I just prefer the xHTML doctype because it's stricter than HTML and the validator catches more problems (I might have to run some tests to verify that though because I'm honestly not sure how different they are in terms of what is/is not allowed. Just need to find a page with lots of errors to test on ...). The Mozilla Developer's FAQ that I linked above has some stuff that explains this. You can also do a search and find lots of debates. These are the two best known articles on the topic:

Sending XHTML as text/html Considered Harmful
Sending XHTML as text/html Considered Harmful to feelings

The second article is a response to the first one. I only have limited knowledge of the issues but I've read both of these and haven't come to a conclusion myself (which is one of the reasons I haven't gone back to the HTML doctype).

Whichever one you choose, definitely do switch to strict. IMO the strict/transitional part is most important.

Edit: Yes, the validator catches a lot more presentational attributes and such under xHTML compared to HTML. Here's another article that explains it:

http://www.robertnyman.com/2005/11/02/html-or-xhtml/

They have: 68 posts

Joined: Dec 2005

Thanks for all the useful comments.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.