Wednesday, March 14, 2012

HTML5 is simpler than possible

See anything wrong with this line of code?

  <link rel=”stylesheet” href=”stylesheets/agilemarkup.css” />

Neither did I. But after copying up a minor style change to my company site, this little line botched up the appearance of the whole site.

The company site was suddenly raw and styleless, as if a developer tools add-in had disabled all styles.

A previous post here, CSS Grammar Considered Wrong remarked upon the muddy expressiveness of the syntax. As an expression of a solution the syntax lacks Focal Alignment. HTML is in a similar condition, and HTML5 especially.

Take another look at the quote character in the HTML:

href=”stylesheets/agilemarkup.css”

Yep, that's a completely different quote character, not the usual double-quote. HTML5's new parsing rules state that we can omit quotes around contiguous attribute values. So when the errant quote character is used, the actual resource that the browser attempts to download is:

”stylesheets/agilemarkup.css”

That is, the not-really-double-quote characters are silently taken as part of the attribute value.

HTML5 browsers are not supposed to complain or flag errors, just gobble up characters and do something predictable. That's what makes HTML5's parsing a simpler solution than possible.
Post a Comment