Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a difference between <a name=""></a> vs id="

Status
Not open for further replies.

robert89

Technical User
Nov 19, 2003
125
CA
Have one of your typical alpah menus a the top of the page with numberous links to various points in the body. Instead of using <a name=""> tags thoughout the document, was thinking of assigning id="" to the various parts of the document (in this case, table cells) i.e. instead of dropping an <a name="a"></a> above the cell, want to tag the cell <td id="a">

Is there a downside to this approach? Is there an upside? In the case of the <a name=""> tag, is it equivalent to an id="".

Thoughts appreciated.
Bob
 
The upside is that it is forward compliant and less messy. Name attribute is being phased out in the newer xhtml versions and replaced by id. The downside is the opposite. Backward compliance. I don't know how good the support for anchoring simple ids is in older browsers. If it works for your target audience, I would go with ids.
 
Hi Vragabond,
Your answer is kind of what I thought. Thank you. As you have mentioned xhtml, can you suggest anything that says in plain english what it is and why one should use it? I am starting to explore and usually gain faster understanding when I begin at ground zero. Then I can make connections. Thanks again.
Bob
 
w3.org says it all... almost too much.

Here's the gist. It's a standard that a bunch of people put together and agree is the "right way." Browsers, then, follow the standards and typically add a little more stuff that is browser spesific. xhtml is what you can expect all new browsers to follow so that your code should look the same cross browser and platform. Browsers adoption of the standards is comming along, and now we just need to get web developers to begin writting more standard compliant code.

[plug=shameless]
[/plug]
 
One major downside is that IDs must be unique. While this is not much of a hindrance in many cases, it can be for others (most notably radio boxes). If you put any javascript in your page it can often be handy to give a group of elements all the same name and then access them as an array of that element. This does not work using IDs.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
kaht said:
While this is not much of a hindrance in many cases, it can be for others (most notably radio boxes).
I hope you don't mean that the id attribute is replacing the name attribute for form elements because name is essential to most form elements right now. Because of this, it was not phased out.
 
Hi rpgfan..
This is useful information. I was asking in general, but obviously it is not a general question. However, my main thought was replacing <a name=""></a> tags with id=, hadn't really given forms much thought.
Will keep your comment in mind.

Thanks,
Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top