Saturday, November 20, 2010

CSS Horizontal List Menu

This tutorial will show you how to make a horizontal CSS list menu. in this tutorial we are not using images or javascript. Just a simple, cross browser compatible CSS list menu.

First of all we will need the HTML for our list menu, this is just a normal unordered list.

<div class="menu">
<li><a href="">Home</a></li>
<li><a href="">About</a></li>
<li><a href="">Contact</a></li>
<li><a href="">Links</a></li>
<li><a href="">HTML</a></li>

in above example I have added a div called menu around the list, I want to do because it helps me remember what part of the code does what, if I ever do it again. Then let's add some CSS to the div called menu surrounding the list.

width: 100%;
font-family:Verdana, Arial, Helvetica, sans-serif;
background-color: #333; }

Again, this is a nice and easy. Class menu cover the entire width of the div is inside and has a dark gray background with font(Verdana, Arial, Helvetica, sans-serif), font size(12px).

Then we add to the list Style and elements of the list.

.menu ul{
margin: 0; padding: 0;
float: left;}

.menu ul li{
display: inline;}

.menu ul li a{
text-decoration: none;
float: left;
background-color: #333;
padding: 10px 10px;

.menu ul li a:visited

.menu ul li a:hover, .menu ul li .current
color: #fff;

Once again, it's all quite simple, you should be able to understand a little &#39;skill CSS code.

This results in:

No comments:

Post a Comment