Problem
You want to create a
horizontal navigation menu out of an ordered
set of links; Figure 3-8 shows
the default, and Figure 3-9
shows what you want.
Solution
First create a properly constructed set of unordered links:
<div id="navsite">
<h5>Site navigation:</h5>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/archives/">Archives</a></li>
<li><a href="/writing/">Writing</a></li>
<li><a href="/speaking/" id="current">Speaking</a></li>
<li><a href="/contact/">Contact</a></li>
</ul>
</div>
Then set the CSS rules for the navigation structure, making
sure to set the
display property
of the list item to
inline:
#navsite h5 {
display: none;
}
#navsite ul {
padding: 3px 0;
margin-left: 0;
border-bottom: 1px solid #778;
font: bold 12px Verdana, sans-serif;
}
#navsite ul li {
list-style: none;
margin: 0;
display: inline;
}
#navsite ul li a {
padding: 3px 0.5em;
margin-left: 3px;
border: 1px solid #778;
border-bottom: none;
background: #DDE;
text-decoration: none;
}
#navsite ul li a:link {
color: #448;
}
#navsite ul li a:visited {
color: #667;
}
#navsite ul li a:link:hover, #navsite ul li a:visited:hover {
color: #000;
background: #AAE;
border-color: #227;
}
#navsite ul li a#current {
background: white;
border-bottom: 1px solid white;
}
Discussion
The first part of the Solution hides the heading. This is done
because the visual representation of the tab navigation design is enough to
inform users that these are navigation links:
#navsite h5 {
display: none;
}
The next rule defines the padding and margin for the box that
is created by the unordered list element,
ul. The line that stretches
across the bottom of the folder tabs is drawn by the
border-bottom property (see Figure 3-10):
#navsite ul {
padding: 3px 0;
margin-left: 0;
border-bottom: 1px solid #669;
font: bold 12px Verdana, Helvetica, Arial, sans-serif;
}