| Turning a list into a navigation bar |
|
|
|
| Articles Reviews CSS | |
| Written by Adi Bach | |
| Monday, 05 March 2007 | |
|
{mos_sb_discuss:19} I’ve received a couple of requests for a description of how I created
the navigation bar that is currently used on this site. The CSS
used isn’t all that advanced, and I hadn’t really thought about
describing it in detail, but after being asked about it I decided to do
a write-up. I’ve cleaned up the HTML and CSS slightly, so if you compare this to what is actually used on the site there will be some small differences. In case I have redesigned by the time you read this, check out the finished example to see what the menu looked like at the time of this writing. The HTML The markup is very simple. It’s an unordered list, with each link in a separate list item:
Why use a list? Because a navigation bar, or menu, is a list of links. The best (most semantic) way of marking up a list of links is to use a list element. Using a list also has the benefit of providing structure even if CSS is disabled. At this stage, with no CSS applied, the list will look like any old (normally bulleted) list, styled only by the browser’s defaults. I’ve given The CSS I’ll describe the CSS I’ve used to style the list in a step-by-step fashion. First of all, I set the margins and padding of the list and list items to zero, and tell the list items to be displayed inline:
Powered by jReviews |
|
| Last Updated ( Monday, 05 March 2007 ) | |
| < Prev | Next > |
|---|







