HTML Follies
January 20, 2014
HTML Follies
DRAFT
Despite all its glories, HTML also has some serious follies. I’ve never thought highly of the W3C in general. They seem to be on a never ending quest to build standards at a snails pace, yet end up with a result that is barely an improvement over previous solutions –if not actually worse. And unfortunately it is too often at an intolerable level of new complexity. For some reason K.I.S.S. seems to have been left off their principles sheet. For some clear examples, consider [XMLST] and [XML-fo]. I think [Web Components] are the latest ranking member.
So let’s go through some of the glaring issues with HTML, what would be an appropriate solution and perhaps make some suggestion for how to mitigate the issue while still under the yolk of current standards.
Headers Ought to be Titles
Presently HTML authors must handle the titling of sections as follows:
<section>
<h2>New Chapter</h2>
<p>...</p>
</section>
We assume here that the author was at least wise enough to put the header in the section and not above it. But why h2 (which is a common choice)? Why not h1 or h3? Well, there is no real reason. The document creator simply choose h2 because it was in suitable font size as setup in the CSS. And therein lies a clear failure of design. The element is not being selected semantically. A proper design would be:
<section>
<title>New Chapter</title>
<p>...</p>
</section>
Alas, HTML has no title element (outside of head). We could argue for a numberless h instead, but it amounts to essentially the same thing. Yet the term title is much more telling. Likewise subtitle is much more telling than any h2 or h3.
What to do now? Our best course of action is to always use h1 for titles and use h2 for subtitles. Headers h3-h6 should rarely, if ever, be of any use.
Padding Undermines Width
Technically this is a CSS issue, but these days it’s not reasonable to separate it from HTML. The two are intractably linked.
Padding should not add width. If the width of an element is specified and a padding is added, then the inner width should reduce accordingly.
Thankfully this has been addressed in the latest HTML version. Hallelujah! …
Open Semantics
Lastly, the ultimate end point of the development of HTML is to separate the markup of structure from that of the meaning of the tags. This is in fact what the W3C was attempting with XML and XSLT. But that approach failed. It was too complicated. A new approach using CSS instead of XSLT could do better.
<chapter>
<p>...</p>
</chapter>
Chapter isn’t a recognized tag. But the CSS could be used to identify it.
chapter { tag: section }
Thus the CSS informs the document to treat chapter tags as if they were section tags.
Current the W3C’s solution to this is Web Components. And while some of the Web Components specification is needed for more complex problems. It is still has a piss poor interface, and is a complete overkill for simple cases like the one above.