Links and anchors: ancient HTML and JS magic in your browser
wearedevelopers.com·6d
🧩Web Components
Preview
Report Post

Have you ever wondered why you use an <a> element to add link to an HTML document? Paragraph is <p>, unordered list is <ul>, image is <img> but why <a> instead of <link>? Well, the reason is that the element both defines where to go to, but also an endpoint to link to, that’s why it is <a> for “anchor”. This goes back to ancient times of HTML, and whilst we don’t use it like this any longer, the echoes of the past still linger in our browsers, as document.anchors, document.links and String.link() and String.anchor().

Links, linked resources, in-page targets and anchors

OK, first of all, the <link> element exists, but instead of pointing to something on the web a user needs to interact with to go to, it [describes a resource to load](https://developer.mozilla….

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help