(This post was originally posted on Up Your A11y - Heading Levels in Reusable Components)
Reusability is Key
One of the key reasons Rea...
For further actions, you may consider blocking this person and/or reporting abuse
This is less about react and more about html in general. I am an advocate of accessibility best practices which are really just best practices in general. But there is one thing I dont ever remember, how do I actually use heading levels, do I need 5 of them, can I use h1 and skip to h3. And so on.
I think it's something we lose sight of so easily - e.g. if the design we've been handed doesn't look like it has very distinct heading levels. I really like WebAIMs section on this in terms of semantic content.
The tl;dr of it is every page should have a single
<h1>
element - the main heading of the page (which describes not just to the user but also to search engines what the page is about). Beyond that heading levels should only ever increase by one, and usually appear nested in sections (by which I just mean parts of the page - I've used section below but it could bediv
or anything) e.g.I think the key is we have to get away from thinking of heading tags as a visual style feature, and understand it's about the core structure of the page - just like any other semantic element.
Once we start to appreciate h1/h2 and so on as 'importance order of title' rather than "make it look X size" then it becomes a bit clearer (or at least to me it does!)
Your last point about size, I often wonder if browsers shipped all heading levels at the same size that would provoke more thought into thier usage. As a beginner you are taught a misnomer that headings denotes size, then frameworks basically affirm this.
That's so true! I guess then I wonder if people would give up on header tags completely in many cases and just style spans or p tags.
At least some headers are better than none! 😁
I guess it's like the italic tag, it's NOT an icon people!
We try hard but there's only so much space in our brains 😂