ids are anchors now

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

ids are anchors now

Post by Ollie Saunders »

Did you know that ids are anchors? I certainly didn't until a few moments ago. So there is no need to ever write this again:

Code: Select all

<p><a name="foo">Text</a></p>
This performs exactly the same function

Code: Select all

<p id="foo">text</p>
This is great for me because most things of importance are already "ided up" for the benefit of CSS. I'm guessing not many people know this because I still see plenty of <a name="" .... in HTML even on professional sites.
HTML Spec wrote:The id attribute has several roles in HTML:

* As a style sheet selector.
* As a target anchor for hypertext links.
* As a means to reference a particular element from a script.
* As the name of a declared OBJECT element.
* For general purpose processing by user agents (e.g. for identifying fields when extracting data from HTML pages into a database, translating HTML documents into other formats, etc.).
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Wow, I'm surprised that more people didn't know about it. I've known and used that technique for a long long time now... It's very very handy.

I've started to use them on sites where they're not even intended. Need to focus someone's attention to a specific part of someone elses page? use an id that they already have somewhere close to where you're interested in.

We use a small url redirector (think tinyurl) here at the office to help our clients locate downloadable software easier and quicker (avg, adaware, spybot, etc), Avg's free download page is a little monsterous, and it can be difficult for those computer "noobs" to find the correct download link.

http://free.grisoft.com/doc/5390/lng/us/tpl/v5#vypln

Send them there, and the download link is right in front of them.
Post Reply