4 ms·
The tag omission/inference rules for <p> come from SGML, and, as presented in WHATWG's HTML spec, seem arbitrary. But actually what they're saying is that a par
by tannhaeuser 5y ago
The tag omission/inference rules for <p> come from SGML, and, as presented in WHATWG's HTML spec, seem arbitrary. But actually what they're saying is that a paragraph is automatically ended on a non-phrasing element. In earlier HTML versions, a definition of flow content was given like this:
<!ENTITY % flow
"%block;|%inline">
where the flow, block, and inline parameter entities expand to strings like a|abbr|... such that they can be used in element declarations as follows:
<!ELEMENT p
(#PCDATA|%phrasing
-(%flow_only|figcaption)>
meaning the content of p can be any phrasing element (and text content), except elements that are in the flow_only category or the figcaption element, capturing precisely HTML5's rules.
While Ian Hickson's initial (HTML5.0) rules were exactly corresponding to those of HTML4.01, later HTML5 revisions (^2) indeed failed to update the prose description for p-terminating elements, for the very reason that those weren't presented as a formal spec (such as a DTD).
In a presentation I held [1] I made exactly that point for the p element, and you might find the derivation of a new SGML DTD grammar for HTML5.x generally of interest.
[1]: http://sgmljs.net/docs/html5-dtd-slides-wrapper.html http://sgmljs.net/docs/html5-dtd-slides-wrapper.html
^2: if WHATWG had bothered to version their specs, and W3C still would produce versioned snapshots of those, at least