Jump to content

name attribute in anchor tag


trinistorm

Recommended Posts

I read on W3 (c8) that the name attribute for 'a' was deprecated Xhtml 1.0. If this is so then why is it still used?

Link to comment
Share on other sites

It's still present, but it is deprecated in favour of the id attribute. Some old browsers don't recognise IDs when using hash-tag navigation though, I believe.

Link to comment
Share on other sites

So what gives? So its still present for backwards compatibility? If so then the REC is a bit misleading.

Link to comment
Share on other sites

I may have misunderstood your question, but I think it's still part of strict XHTML.http://w3schools.com/tags/tag_a.asp
I was referring to the documentation at http://www.w3.org/TR/2002/REC-xhtml1-20020801/#dtds. The part about
Finally, note that XHTML 1.0 has deprecated the name attribute of the a, applet, form, frame, iframe, img, and map elements, and it will be removed from XHTML in subsequent versions.
Link to comment
Share on other sites

You're correct. name is deprecated in XHTML 1.0 and dropped from XHTML 1.1, which is the current recommendation. If you need bookmark ability (the # tag) your <a> element should have an id attribute. Modern browsers use the id in a bookmark tag the way older browsers used the name. Any browser that recognizes the 1.1 DTD will behave correctly. I'm not sure, but I believe this is true of IE6, which is the oldest browser I ever worry about. IE6 behaved correctly (in this regard) before Mozilla did.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...