Anchors, IDs, CSS Signatures and the Joy of Cleaner Code
I was halfway through writing a post on streamlining and clean code yesterday (to be published as and when; you know how it goes) and lo’ & behold this little gem from Perishable Press dropped in my RSS feeds this morning.
IDs are anchors, too describes how any ID tag (ie. id=“name”) can act as an anchor link on a page thus negating the use of extraneous <a name="anchorname"></a>
h4.Quick note on CSS signatures
This also means that if you happen to use a CSS signature on your pages you can simply use that id as your link to ‘top’.
In simplest of terms it is adding your site url to your page to allow your viewer to tailor their user style sheet specifically to your site (say if they really wanted to view the background in red and text in white. It’s an accessibility thing).
So to the <body>
tag you would add an altered form of your web url. So, for this site, I would us the following: <body id="foolbox-info">
and the user could then change the stylesheet thus:
body#foolbox-info { background:#f00; }
#foolbox-info h1 { color:#fff; }
Then your ‘back to top’ link would run thus: <a href="foolbox-info">Top</a>
.
Simple, n’est pas?