In case you are not concerned about supporting IE7 and below, you can utilize the :before
pseudo element without the need for extra markup:
#navigation links {
display: block;
position: relative;
padding: 2px 2px 2px 30px;
min-height: 20px;
line-height: 24px;
}
#navigation links:before {
content: '';
position: absolute;
left: 0;
top: 2px;
width: 24px;
height: 24px;
background: url(http://static.tumblr.com/wgijwsy/itFlt1l8x/links.png);
}
links#rss:before { background-position: -24px 0 }
links#facebook:before { background-position: 0 -24px }
links#twitter:before { background-position: 0 -48px }
If IE7 support is essential, you can include a span
within the anchor tags and replace a:before
with a span.icon
.
Additionally, ensure that your h2
is positioned outside of the ul
, as having it inside is considered invalid HTML.