Replacing named anchor with id attribute on element?

General discussion about web technology.
Post Reply
barbaz
Senior Member
Posts: 10847
Joined: Sat Aug 03, 2013 5:45 pm

Replacing named anchor with id attribute on element?

Post by barbaz »

Currently (at least in SeaMonkey) it's possible to use the id attribute of an element for same purpose as

Code: Select all

<a name="...">
For example, to scroll to a point "foo" in a page, the following appears equivalent:

Code: Select all

<a name="foo"></a>
<div>blah blah content</div>

Code: Select all

<div id="foo">blah blah content</div>
Either way, can click a link like this

Code: Select all

<a href="#foo">link</a>
and end up scrolled to the blah blah content.

How stable is that behavior / how much can I rely on it being there? Is this a browser quirk or standard behavior?
I discovered it by accident and can't find anything about it on MDN nor the WHATWG standards.

Thanks
*Always* check the changelogs BEFORE updating that important software!
-
Post Reply