tags:

views:

32

answers:

2
+1  A: 

I didn't know this either. It's official, though. From the HTML 4.01 spec:

Destination anchors in HTML documents may be specified either by the A element (naming it with the name attribute), or by any other element (naming with the id attribute).

Wikipedia knew it too:

In HTML applications, http://www.foo.org/foo.html#bar refers to the element with the id attribute that has the value bar (i.e., id="bar") in the document identified by the URI http://www.foo.org/foo.html, which is typically the location from which the document would be obtained via the Internet. The deprecated name attribute can also be used for this purpose in the same manner.

Pekka
+2  A: 

Well HTML 4.01 is pretty clear ...

12.2.3 Anchors with the id attribute

The id attribute may be used to create an anchor at the start tag of any element
(including the A element).

This example illustrates the use of the id attribute to position an anchor in an 
H2 element. The anchor is linked to via the A element.

You may read more about this in <A href="#section2">Section Two</A>.
...later in the document
<H2 id="section2">Section Two</H2>
...later in the document
<P>Please refer to <A href="#section2">Section Two</A> above
for more details.

If it's any consolation, you're not alone. Somebody commented on another answer of mine on SO recently, saying the same thing.

It started with HTML 4, so if you learnt your HTML before 1998/9, the change was not a major one compared to the other changes and therefore not the easiest thing to notice. I didn't really start to learn HTML until 2001, so HTML 4 was where I began.

Alohci
OK, well that clears it up! Thanks. And yes, I "learned" HTML quite a while ago and really haven't gone back to study the minutiae since then for things that I thought I completely understood!
Pointy