Slide 5.26: CSS pseudo-element (cont.)
Slide 5.28: CSS navigation bar (cont.)
Home

CSS Navigation Bar


Having easy-to-use navigation is important for any web site. With CSS you can transform boring HTML menus into good-looking navigation bars.

Navigation Bar = List of Links
A navigation bar needs standard HTML as a base. The following examples build the navigation bar from a standard HTML list, so using the <ul> and <li> elements makes perfect sense:

     


To remove the bullets and the margins and padding from the above list, use the CSS on the right:
 ul {
  list-style-type:none;
  margin:0;  padding:0; }

Vertical Navigation Bar
To build a vertical navigation bar, style the <a> elements in addition to the code above:
 a {
  display:block;
  width:100px;
  background-color:#dddddd; }

Demonstration
The following demonstration shows how the script of HTML and CSS is displayed on the Web: