When XHTML goes round the bend


XHTML is a great idea, once you understand the shear Lovecraftian terror that is SGML, of which HTML is a child. Very few people understand all of SGML, including me, but here’s the important point: SGML has all kinds of rules to imply elements. If you don’t close your OPTION tag in HTML, the browser will create a node for the end tag anyway when in interprets that document. That’s great, but in the case above, the browse does something completely predictable. However, there are plenty of ambiguous cases of what missing nodes should be created and trust me, brother, you don’t want to go there. But this is a horrid topic for another day.

The problem with XHTML is that it is XML. So when you need to add a SCRIPT section, you need to escape it XML-style like this

<script type="text/javascript">
{js code here}

Wow! That’s ugly! But wait, there’s more. No Javascript engine knows anything about XML CDATA blocks so you need to hide that with Javascript style comments. So you get this:

<script type="text/javascript">
{js code here}

What a mess! If this alone doesn’t make you run for keeping your JS in a separate file, nothing will.