Skip to content

Write HTML, the HTML Way (Not the XHTML Way)

https://css-tricks.com/write-html-the-html-way-not-the-xhtml-way/ by Jens Meiert, 29 Mar 2022.


I really like Jens’ writing. He understands the – what should be very obvious as it’s the one programming language you cannot omit if you want to publish web pages – importance of HTML, and affords it the consideration normally reserved for javascript and, to a lesser extent, CSS.

Ah, XHTML – I’ll raise your 1.0 doctype with a 1.1… When HTML 5 came along sanity, or rather, pragmatism was restored. Jens is right when he observes we still exhibit XHTML habits – I couldn’t use anything but lowercase tags and it would feel very weird not closing a p. On the other hand, my hex codes are always uppercase and I was more than happy to drop />

Having said that, this pragmatism cuts both ways. Does it really matter if you retain verbose XHTML habits? I wonder how much is to be gained from paring back your markup, especially compared to, say, using javascript judiciously. Perhaps closing our ps instils discipline, or at least the feeling of discipline and order.

But <input required readonly> is indeed tersely beautiful. Because HTML isn’t XHTML we get the chance to explore these different syntaxes knowing we’re not going to break anything.