Developers’ Weblog

FOSS hosting by
HostEurope Logo

Developers’ Weblog

All 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

How to handle XHTML properly

2020-04-30
Tags: bug rant

OK, toned down on the rant, I already did enough in the commit messages…

My webpages are valid XHTML/1.1. But what does that mean?

I write them conforming to XHTML/1.1, with spaces before the “/>” sequence. This allows me use of tools such as xmlstarlet to operate on them as XML files, and even validation against the DTD, offline. That “extra” space allows HTML browsers to process them as HTML. I’m now, as per some part of the spec, supposed to serve them over HTTP as application/xhtml+xml content type — two questions: why does the XHTML spec say anything about HTTP, and, why doesn’t another spec agree with it?

Turns out, much later, it has a reason — the XHTML/1.1 spec is mostly just a diff against XHTML/1.0 Strict, which is just a diff against HTML 4.01 Strict. The HTML5 spec (both concurrents, W3C and WHATWG) is however standalone and merges the XHTML parts. It, now, in contrast to the three older specs I mentioned above, has a side note, in a tag-specific chapter (with nothing mentioned in the XML part), explaining a parsing difference (basically, in XML mode, it doesn’t skip a leading newline immediately after an opening pre tag). Fucktards.

I’ll just serve my XHTML/1.1 files only as text/html now, even if I get an Accepts for XHTML+XML from the request. (The HTML5 spec, at least one, now forbids me to use XML namespaces, both for things like embedded SVG (I am supposed to just use an <svg> tag) and custom ones, e.g. to embed DC in SVG… but we all know just how binding this is for browsers, and that browsers will handle all kinds of things under the sun, and then some, so I’m ignoring this, ’sides, I even don’t write XHTML5 at all…)

Anyway the too-large space around section and subsection headers in our HTML manpages is now “fixed”, for some very low value thereof (but with HTML and CSS the expectation is extremely low anyway…).

MirBSD Logo