←back to thread

197 points OuterVale | 2 comments | | HN request time: 0.461s | source
Show context
nfw2 ◴[] No.46227886[source]
I'd like to propose for the list:

Default heading styles should not have equal top and bottom margin. Headings should be closer to the content they label than to the content they are setting their content apart from.

h1, h2, h3 should not have different styles. it's an anti-pattern that leads to broken accessibility

replies(4): >>46228089 #>>46228201 #>>46228647 #>>46230155 #
0xfffafaCrash ◴[] No.46228201[source]
moreover h* is just broken whenever dealing with more dynamic content — it simply can’t reasonably be made to work according to accessibility recommendations — and the accessibility guidelines around never skipping a level themselves are ridiculous given the practical reality that dynamic content exists and we have only h1, h2, etc. to work with — the readers and specs are what need to adapt here, not the entire internet

there should really be one header tag and its level should be based on some nesting depth

and don’t get me started on the maintainability mess that is z-index… better we have a system to centrally maintain an ordering list than a distributed one which only works reasonably consistently if you already know everything in the whole system

replies(3): >>46228470 #>>46229042 #>>46229721 #
nfw2 ◴[] No.46229721[source]
The problem with trying determine heading depth automatically is the depth is not something that can be deduced just by the structure. If headings are siblings, for example, the may be on the same level semantically or not.

One way I've dealt with this in react is combine a Heading component with ContentGroup component. Each content group needs exactly one heading, and heading can't exist without it. Content group can contain other content groups. The tag for heading can then be determined by how many content groups are in the tree above it.

This works pretty well ime, but it can be hard to get devs to use (or think about accessibility at all).

replies(1): >>46230921 #
1. wongarsu ◴[] No.46230921[source]
That's how html should have been designed from the start. HTML is originally designed as a very flat hierarchy, e.g. h1 p p p h2 p p h2 p p h3 p h2 p just following each other. When really it would make much more sense to have h{p p p h{p p} h{p p h{p}} h{p}}.
replies(1): >>46231076 #
2. yiiii ◴[] No.46231076[source]
That's what sectioning elements [1] like <section> and <article> where once introduced.Opposite to just using <div> elements their purpose was to create a real document outline, where it would have been possible to only use <h1> and their level would be determined by how deep the section is nested, but this approach was never really adapted.

[1] https://www.w3schools.com/html/html5_semantic_elements.asp