now with added Masterweb and IB Geek Girl

spider web Ecanus•net :: Code Snippets

My favourite code snippets

These are just some of the code snippets I couldn't live without. Okay, so maybe, I could live without them – they're not like air or food or anything, but they're the code snippets I use most often, and the ones that make life easier for me. I've tried to group them into logical groups – HTML (and XHTML), CSS, and PHP. I hope you find them useful.

These are just a few of my favourite ones. I'll be adding more as soon as I get a chance. Click the links below to see the snippets.


Identifying external links

HTML: <a class="external" href="mylink.html" title="My external link">My link</a>

The HTML for the link is used as normal, and is given the class "external".

CSS: .external, .external a:link { background: url(../images/externallink.gif) no-repeat right; padding-right: 10px; }

The CSS specifies that a background image "externallink.gif" should be used for this class of link, and that gives it some right padding of 10px to ensure there's some space between the link text and the background graphic.

The Image: (right–click and "Save As" to save the image)

Result: My link