Call: 847.544.0118

Email: ksj@twelve8.net

Categories

A clever bit of CSS

June 30, 2009

A while ago, I was directed to this prototype for the mozilla.org redesign, notable particularly for it’s use of an intelligent, fluid grid. I bookmarked it within a folder I keep for quick design inspiration, since there are several aspects of the design that I think are pretty great. Looking at it again the other day, I discovered a clever bit of CSS coding.

‘looking for’ menu from mozilla.org redesign

I’m pointing to the bullets separating the links in this menu. The anti-aliasing gave away the fact that they were images, not “text.” Frequently, sites will use a pipe (“|”) to separate links like these. In these cases, the pipe is either separated from the link with regular old spaces, or appended using :before or :after. Not semantically ideal. Some sites I’ve seen have placed the separators (be they bullets, pipes, or otherwise) in separate <li>s. Definitely not semantically strong, though I admit that I’ve turned to this approach before, even after semantic enlightenment. The key advantage is that there’s no need for :first-child and/or :last-child to avoid placing spacers to the left of the left-most link or right of the right-most. Other sites recreate the same effect using the CSS border property (along with padding for spacing). Much better, but limited.

But Happy Cog (I think this was done by Happy Cog) did something else here: they used a background image, positioned in the left of each <li>, along with padding-left to separate the link text and the bullet.

Here’s the (relevant) code:

#utility li {
background: transparent url(/i/screen/bullet_utility.gif) no-repeat scroll 4px center;
padding-left: 14px;
}

I see myself turning to this approach in the future.

Did you know…?

Of the twelve signs of the Zodiac, 8 are animals (if you count Sagittarius, a centaur)

How do I get in touch?

Brighten my day with an email.

Or, if you know that you’re interested in working with twelve8, fill out this project idea sheet and send it to ksj{at}twelve8.net .

Or give me a call. It’s 847.544.0118

You can also download my vCard

© 2009 Kyle Jacobson. All rights reserved | Accessibility statement