« Two Column Lists in CSS | Main | Autorun Issues on Windows/Mac »

February 22, 2005

Page anchors are really IDs

I noticed a finer point in inter-page navigation and the use of the DOM. An anchor is really just another ID. This realization opens some new doors.

Consider the following - used to as a link to a different section of a page.

‹a href="#anchor"› The is the link text ‹/a ›

Generally, when linking to another part of the page, you insert an 'anchor tag' where you want to jump to. Like so:

‹a name="anchor"›‹/a›

Here's the point: if have a markeup element with the ID set to say 'anchor', there is no need to add the ‹a› ‹/a› tags. Such as

‹h1 id="anchor"›The Title Blah Blab ‹/h1 ›

The navigation still works. No need to add anything else. The ID is the anchor name. A subtle but powerful point.


This is another example how CSS and the DOM change the coding paradigm within well built pages.


Posted by pgraber at February 22, 2005 06:06 PM