Why I use HTML (instead of xHTML)

Sean of Elementary Group Standards asked me, as part of a CSS Spring Reboot 2006 questionnaire, why I used HTML 4. Was using HTML instead of xHTML a concious choice on my part? Absolutely.

While the other people who were questioned managed to keep it nice and concise, I managed to write up a whole bucket load of words about it. As others asked me why I made sure Bite Size Standards is HTML 4, I’ve decided to post my answer here too.

As published on Elementary Group Standards:

“I’ve used xHTML for 5 years, from 2001 til 2006. My original reason for using it was that it is supposed to be the future. It would have benefits like in-line SVG and MathML. It was presented as TheThingToUse(tm) with CSS.

There are two things about xHTML which make it a poor choice for (public) sites. Both of them have to do with xHTML’s mime-types. In short, xHTML can be sent with text/html or application/xhtml+xml as the mime-type. On the web xHTML is usually sent as text/html, as Internet Explorer (which has 83+% market share) doesn’t support the other mime-type. Both mime-types are valid for xHTML 1.0, but (supporting) browsers do handle them differently.

It’s the handling of the same code differently where xHTML’s problem lies. When xHTML 1.0 is sent as text/html, it is handled as HTML. This means that it has zero user benefits over HTML 4.01.

When sent as application/xhtml+xml, you could use MathML – but – the browsers will also apply draconian error handling. This way users visiting the site will be punished (by not being able to see the site) for mistakes by the creator (which could be the developer, the CMS, the person updating the text or indeed the user her/himself just writing something). Simple things like a misplaced “&” on a page (instead of “&“) will completely shut off a page from its users.

So not only are there no benefits over HTML 4.01 because you have to send Internet Explorer text/html – you do get user-punishing error handling from other browsers if you decide to send to them the application/xhtml+xml mimetype.

No benefits but increased headaches? Mwa, count me out.

Some people might say ‘but xHTML is the future!’ This may well be, but is of little consequence. The future versions of xHTML (1.1 and 2.0) are not backwards compatible with xHTML 1.0, so writing xHTML now gains you little in the future. Furthermore HTML 5 is coming. Who says that can’t be the future?

My recommendations for writing HTML? Use the doctype ‘HTML 4.01 Strict’ and write your code as xHTML compatible as possible. This means self-closing tags in the body, but not in the head.*

*Little known fact: It’s actually in the spec that you’re not allowed to self-close the meta or link tags. Quite silly in practical terms, and I would suggest to the HTML 5 people that they change that[1. And lo and behold they did! In HTML 5 it’s completely up to you whether you self-close tags or not.].

I hope this answers all the questions people have, but if you have any more (or dare to question my arguments!) don’t hesitate to use the comment form accompanying this journal entry.

8 replies on “Why I use HTML (instead of xHTML)”

I know you do; And if it’s you – who knows xhtml by hart – using it, it can guarantee good code. However, just one lil’ typo and you’ll be punnishing users for it.

And for the web in general, it’s much better to have a “do or kinda do too” approach, wouldn’t you say?

I remember reading in the SitePoint “DHTML Utopia” book that xHTML has some nasty weaknesses when dealing with DHTML too.. Can’t remember the specifics though.

Sometimes we just need to be reminded that, although xHTML may be newer and shinier, HTML4 is still *valid*, right?

Whoah, how DAMN cool is that!?!

I put in my web site, and you look to see if I have a favicon set up, and use that as my glyph! Gold star to the boy at the back!!

It’s not so much a “DHTML weakness” as much as xHTML can have a different DOM. So two pages which might look the same, might have elements you need to reference differently in your JavaScript.

Not only is HTML 4 valid, in most of the cases it’s JustAsShiny(tm).

And about the ‘glyph’: That’s just a favicon plugin for wordpress – so while I can’t take too much credit for it, I’m glad you like it!

Tah muchly!

This is a most concise explanation of why NOT to use XHTML.

Great for waving at non-techy clients and management. :o)

Umm… from the manual for the link element:

Start tag: required, End tag: forbidden

and meta:

Start tag: required, End tag: forbidden

So, what’s with the little known fact? Or did someone else give you false information?

Comments are closed.