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.