Tech Tip: Empty tag in XHTML served as text/html
If you serve XHTML (= HTML
written using XML grammar and conventions) as
Content-Type: text/html
, you may be tempted to write an empty
<div>
tag as a standalone XML tag with a trailing
slash using <div id="my_anchor" />
. Don’t do that, and
instead write a pair of opening and closing tags, e.g:
<div id="my_anchor"></div>
.
Using the first form confused both Firefox (24.2.x in my case) and Google
Chromium (whatever shipped with Mageia at the time), and made them misrender
my page, despite the fact that it validated as valid XHTML. Perhaps I should
have considered putting the id=".."
inside a meaningful
sub-section of the document, but I implemented something for skipping a
section navigation menu.