Creating Pipe-Separated Menus with Unordered Lists

Published Sunday, May 27, 2007 in (X)HTML, CSS, Semantics, Web Standards

Pipe-separated menus are quite common over the internet, especially for footer-navigations.
As we all know, menus are simply lists of links and should therefore be marked up as such. Even so you see plenty of footer-navigations that are marked up with nothing more than the paragraph-element and the separating character is actually in the source code.
Thanks to the :after pseudo-element we can add the separator using CSS, and it's very simple.

The HTML

<ul id="footer-navigation">
    <li><a href="#">Top</a></li>
    <li><a href="#">Valid XHTML</a></li>
    <li><a href="#">Valid CSS</a></li>
    <li><a href="#">Get Firefox</a></li>
</ul>

The CSS

#footer-navigation {
    margin-left: 0;
    padding-left: 0;
    list-style-type: none;
}

    #footer-navigation li {
        display: inline;
    }

    #footer-navigation li:after {
        content: " | ";
    }

    #footer-navigation li:last-child:after {
        content: "";
    }

That CSS simply says that there should be a " | " after every li in the list but the last one.
You can of course use any character you want.


Rate It


Bookmark It

  • del.icio.us
  • Digg
  • Furl
  • Google
  • Technorati
  • Ma.gnolia
  • BlinkList
  • Blogmarks
  • Rojo
  • StumbleUpon

Comments

2 comments so far, why don't you post one too?

Aron

Wednesday, June 13, 2007 | View all comments by Aron

does not work in ie 6

Ante

Wednesday, June 13, 2007 | View all comments by Ante

Doesn't work in any IE version as far as i know. But i'm all for using the latest techniques and letting people who choose to use a crappy browser have a crappier experience.

If more people did that less people would be using IE.


Comments closed

Comments are closed



Post It

From June 02 to April 23

  1. Mogrify is what you're looking for if you want to convert multiple images to multiple other images in ImageMagick
  2. Tommorrow, finally, the inFamous demo will be friggin availble on PSN!! Suweeeeeeeeet
  3. Fuck canvas is cool, I've started playing around with old 3D-shit again :)

May 2012

S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31


Recent Comments

  1. quick quid on Bye, bye exscale!:
    jhtmpl...
  2. cheap viagra on Bye, bye exscale!:
    nsikku...
  3. payday loans on Bye, bye exscale!:
    ixrhvy...
  4. buy cialis on Bye, bye exscale!:
    lqlokhr...

Style Switcher

The style switcher allows you to change the look and feel of exscale.se.
Only CSS and JavaScript are changed. The XHTML stays the same.

For more information about the styles, check the styles page.


Categories


Random Quote

Lycka till för evigt! - Totte


Random Images




Answer This!

Do you find the "scroll-pagination" annoying? (If you don't know what it is, scroll to the bottom of the first-page)


Blog Roll