ids are anchors now
Posted: Sat Mar 17, 2007 4:03 pm
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:This performs exactly the same functionThis 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.
Code: Select all
<p><a name="foo">Text</a></p>Code: Select all
<p id="foo">text</p>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.).