HTML 5 syntax

One advantage XHTML has over HTML is that it has simpler syntax rules. If you want your documents to validate you can’t pick and choose – you need to use lowercase for tag and attribute names, close all elements, quote all attribute values, and give all attributes a value.

Some find those rules restrictive. I find them extremely useful since they give developers less room for coding choices that are mostly aesthetic but make collaboration and maintenance harder and slower.

HTML 5 does not have the same syntax rules as XHTML. It allows you to pick and choose – you can mix tag and attribute case as you wish, quote some attribute values but not others, and leave out closing (and in some cases opening) tags for some (but not all) elements.

So once HTML 5 becomes a viable option, how can we avoid having teams of web developers spending their time discussing which syntax to use instead of working on the project their clients pay for?

Robert Nyman suggests some possible solutions in The HTML5 Syntax Options Problem, coming to the conclusion that the most realistic scenario is having an option for stricter syntax in the validator.

Another situation when having different markup options is confusing is teaching, which Lars Gunther describes well in Pedagogic validation of HTML. Since I do some occasional teaching I can relate to the examples he provides.

I think both of these scenarios – development and teaching – would be improved by having a “strict” or “XHTML-ish” option in the validator. Actually, if it was up to me I’d turn it around and make that the default option.

Posted on December 2, 2009 in HTML 5, Productivity

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.