Hacker News new | ask | show | jobs
by vivegi 1092 days ago
Name Anchors has been a thing in HTML for a very long time (at least since HTML 2.0 spec [1], if not earlier).

  <a name="myanchor"><h3>Things to do</h3></a>
If the CMS supports name anchors, you can just bookmark it as

  https://example.com/foo.html#myanchor
Of course, authors are not mandated to follow named anchors for their document fragments, so this is just a best practice.

[1]: https://www.w3.org/MarkUp/html-spec/html-spec_7.html#SEC7.4

2 comments

Post JS build pipelines and web packers, most element names and classes are just minified garbage.

Sadly most web devs don't give a damn about accessibility anymore :(

Especially not in the React and Angular based ecosystems and toolchains. Server-side rendering was popular for a while, but even then the generated HTML codes were pretty useless for A11y focussed products.

You don’t need named anchors to accomplish the goal of URL fragments. ID attribute values on any element accomplish the same goal.
Yes. The name/id choice recommendation has been evolving since the original HTML spec. For modern browsers (in 2023), you are right about the id attribute. Some very old browsers needed the name anchors.