3 ms·
That's not entirely correct. HTML allows heading elements (<h1>-<h6>) wherever "flow content" is expected, but not in eg. "phrasing content", and also not in a
by tannhaeuser 6y ago
That's not entirely correct. HTML allows heading elements (<h1>-<h6>) wherever "flow content" is expected, but not in eg. "phrasing content", and also not in a number of content models allowing flow content generally but not heading elements specifically such as those for the <address>, <dt>, <th>, and <legend> elements.
What that means is that eg. a <h2> element automatically ends an open <p> element when not closed explicitly. WHATWG's HTML spec clumsily expresses these SGML tag inference rules by enumerating explicitly all elements that end <p> elements (and of course, WHATWG's HTML specification process, as would be expected, then "forgets" to update the enumeration when new elements are introduced in later specs):
> A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul, element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element
Source: SGML DTD for W3C HTML 5.2 [1], prepared from W3C's HTML 5.2 spec, which in turn is derived from (an older version of) WHATWG's HTML spec.
[1] http://sgmljs.net/docs/w3c-html52-dtd.html#element-categories http://sgmljs.net/docs/w3c-html52-dtd.html#element-categorie...
- leetrout 6y agoHuh. I had no idea! Thank you for sharing this with me!