3 ms·
Maybe I'm mistaken, but weren't the <h1>, <h2>, etc elements defined to be essentially equivalent in HTML5, with the number being there for legacy agents only?
by xg15 10y ago
Maybe I'm mistaken, but weren't the <h1>, <h2>, etc elements defined to be essentially equivalent in HTML5, with the number being there for legacy agents only?
I.e., non-legacy browsers should already ignore the number and only take nested <section> elements into account when building the tree and calculating the heading level.
So the following:
<h1>Heading</h1>
<section>
<h1>Sub heading</h1>
...
</section>
would be perfectly valid.
- extra88 10y agoBrowsers haven't implemented it.
- deleted 10y ago[deleted]
- adiabatty 10y agoNot quite. You can do things like this, and the `section > h2` will properly be a subheading of the `section > h1`, which will be a subheading of `article > h1`: <article> <h1>Why Fancy Keyboards Are Great</h1> <section> <p>Fancy keyboards are wonderful. Here's why:</p> <h1>Ergonomics</h1> <p>Not contorting your body into a pretzel is wonderful.</p> <h2>Low-force keys</h2> <p>You can get fancy keyboards with Gateron Clears to make typing easier.</p> ... </section> </article> This sort of thing is handy if your blog software (Jekyll, Hugo, etc.) mechanically pastes the output of a Markdown processor into a space reserved for blog posts. Particularly if you want to use h1 elements in your Markdown source and have things turn out right without rewriting header levels. Like with a lot of document-markup doodads, there's an automated checker for this sort of thing: https://gsnedders.html5.org/outliner/ https://gsnedders.html5.org/outliner/