Bad habits from XHTML (to unlearn)

With the impending completion of the HTML5 spec, I thought I’d summarize the major differences between XHTML and HTML5 that affect me the most in my daily blogging and web development. Figured this might be useful to others.

HTML5 Fist

Void elements (those that cannot contain text or other elements, and thus don’t require an end tag) don’t need to be closed with a nitpicky trailing slash (see: There are only 10 legal XHTML empty tags for more)

<br> is ok!
<img src="image.jpg" alt="image"> is ok!

Unquoted attribute-values are ok (if the value doesn’t contain spaces)

<input type=checkbox> is ok!

Empty attributes (those that don’t require a value) don’t need values

<input type=checkbox checked> is ok!

The acronym element is now obsolete, use abbr instead (which is conveniently 3 characters shorter)

<abbr title="hypertext markup language">HTML</abbr>

Viva HTML!

5 Comments

I know XHTML was stricter, and much closer to XML in its design…but I eventually grew fond of it’s fickleness.

The thing is that XHTML was strict purely for the sake of masochism (riding the coattails of XML). The spec was developed with little or no input from actual browser vendors, while laboring under the assumption that a stricter spec would benefit them.

What it didn’t take into much consideration is that the producers of [X]HTML (aka us) rarely check for validity, and the browser vendors, knowing this, still have to produce a product that results in a positive output.

The truth is, you probably never grew fond of serving up XHTML content with the application/xhtml+xml mime type (as Internet Explorer never supported it) or enjoyed the joys of draconian error handling. Which means that, all along, from a web browser’s perspective, you’ve just been producing really funky HTML.

So really HTML5 is awesome, as it says, “What you are doing is ok, because you’ve been doing it. Let’s move forward.”

Agreed, I’m tending more to the school-of-thought that says, if the code is standards compliant, then screw the browser (I say that with my utter bias against IE). I’m more Firefox, though Chrome is starting to make an impact too…

I agree that XHTML had a lot of issues (content type, error handling, etc.), but I will miss the insistance on consistency in how it was written.

The HTML/HTML 5 rules could also be written like this:

* You don’t have to quote attribute values, unless you do!
* You don’t have to close tags, unless you do!

HTML 5 is a big step forwards in a lot of ways, and I know that XHTML syntax is still allowed, but I can’t help but feel sad when I see the return of old skool HTML syntax.

XHTML vs HTML5 reminds me a lot of my feelings during college about studying Engish vs Linguistics. English was a prescriptive field, singularly concerned with enforcing the “right way to do things” all the while turning a blind eye to the forces of language change. Linguistics on the other hand was a descriptive field, concerned with describing the way people do things and realizing that underlying it all are some consistent rules to be discerned.

I’m not trying to say HTML is a natural language, but given it’s produced by gazillions of individuals, CMSs, companies, tools, etc., it starts to take on the aura of a natural language: change happens bottom up instead of top down, people make creative assumptions about what they can and cannot do (like leaving out the tbody element). And if it works in the browser then it’s right.

Another way to put it: worse is better. And oh yeah, I ended up majoring in Linguistics.

Care to Comment?

Or if you'd prefer to get in touch privately, please send me an email.

Name

Email (optional)

Blog (optional)