I propose to change the HTML spec for heading elements <h1>, <h2> etc. to no longer allow nested headings, i.e. heading tags nested inside other heading tags.
Currently it is allowed to have nested headings, e.g.
<h1>Top level <h2>First nested level<h2>Second nested level</h2></h2></h1>
Reason for this suggestion:
- This doesn’t make sense from a semantic point of view
- I can not think of a single use case where headings should be nested inside each other
- Current implementation causes problems: The following page is well known for missing all the heading end tags which causes all sub headings to be nested inside each other, on some systems this even causes the browser to crash:
Embroidery Trouble Shooting Guide
- Change the spec to not allow nested headings. Open for suggestions what exactly is allowed inside headings, but I suggest to base it on <p> element with some additional elements allowed inside headings.
- Change browser implementation of headings. All heading opening tags should auto-close any heading that is already open
So the following code
<h1>Top level <h2>sub heading</h2></h1>
would show two parsing errors (missing </h1> end tag before <h2> and orphaned </h1> end tag after </h2>) and would be treated as