Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Preferably, you should use a single <h1> per page—this is the top level heading, and all others sit below this in the hierarchy

From the MDN docs on headings and paragraphs [0].

Yet this article is unclearly stating that it isn't preferred but required seeing as the places it semantically makes sense to use multiple H1 tags in a page will now log warnings to developers ( article, aside, nav etc .. )

The article mentions confusion yet the defacto documentation on the web encourages the confusion by not being more specific...

0. https://developer.mozilla.org/en-US/docs/Learn_web_developme...



It's a weird one. HTML does have a TITLE tag. But it's supposed to go in the HEAD. The BODY does not have a TITLE. Any word processor uses something called a Title (and Subtitle) at the top of your document and then things Heading1 for sections. HTML originally didn't have dedicated tags for this; just h1-h6 (because surely six is enough for anyone). So you get this weird off by one error that arises from the notion that HTML just lacks essential tags. So you use H2 to mean Heading1. Because H1 is reserved for the title. Never mind about sub titles. Not a thing in HTML.

Mostly this is because Tim Berners Lee probably didn't think this one through properly decades ago. And it was never really fixed. These days you can just invent your own tag names and style them of course. Which is a useful trick that is a bit underused. The structural semantics are nice for things like accessibility, SEO, and a few other things but otherwise HTML is a really poor choice of a format to exchange structural information. You generate it from other formats preferably. Writing it manually is a PITA. Even if you are a developer. Things like Markdown exist for a reason (and perpetuate the problem).


I don't think it's fair to blame Tim Berners Lee for this. The WWW was supposed to serve documents. The TITLE would have been rendered by your browser, and in fact, it still kind of is, in the window title bar.

The Web has long departed from that vision however; very few pages, if any, could still be considered documents.


I think it is fair to say TBL didn't come up with a perfect design, and he never set out to. He solved a simpler problem than the ones we have now, and that's just fine. He might be the last person to imagine HTML would have continued on with so much of its original design intact.


The article says

> Do not rely on default browser styles for conveying a heading hierarchy. Explicitly define your document hierarchy using <h2> for second-level headings, <h3> for third-level, etc.


The argument I was making was what is why would

    <main>
    
    <h1>Main Heading</h1>

    section..h2... Etc

    </main>
    
    <aside>
    
    <h1>Aside heading</h1>

    section...h2...

    </aside>
Be incorrect? The original html standard clearly stated this was acceptable but now there should only be a single H1 which is the page heading and all other headings should be H2 and lower. What if the page content doesn't actually have a single main heading? This change fundamentally changes the semantics of something which has had unclear semantics for decades and which actually rendered what I typed above correctly in the past. Now it would not be rendered correctly anymore.


The spec allows multiple top-level headings: https://html.spec.whatwg.org/multipage/sections.html#heading...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: