4 ms·
> If you want heading anchor links, go for something like[...] ...something like `a > h1`. Anchors wrapping block headings feels...wrong, but it's valid HTML5.
by SippinLean 6y ago
> If you want heading anchor links, go for something like[...]
...something like `a > h1`. Anchors wrapping block headings feels...wrong, but it's valid HTML5.
Most browsers will set the inner `h1` as display: block so the click/tap target for the `a` becomes larger. (`h1 > a` with `display: block` would have the same result though).
Also make sure that content isn't being duplicated for the user, `a` and `h1` are waypoints for users. `aria-` attributes can help you here.
- chrismorgan 6y ago`a > h1 > title text` has basically the same set of problems as `h1 > a > title text`. I’m saying that the anchor link should be separate from the title text, and largely hidden (from screen readers and keyboard navigators).