Tel: (314) 266-9321
You are here: Home / Blog / Development Sandbox / HTML/CSS / Simple HTML Horizontal Menu
Published on December 21st, 2009 by Tanner Hobin and filed under HTML/CSS
For novice website designers a simple horizontal menu can be pretty daunting. I know it caused me frustrations starting out. In this post we analyze how to create a cross-browser compatible and W3C valid HTML/CSS horizontal menu.
<ul class="menu">
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
<li><a href="#">Link 5</a></li>
</ul>
ul.menu {
list-style:none; /* remove bullets */
background:#999;
overflow:auto; /* span the width of the container */
padding:0; margin:0; /* reset browser defaults */
height:100%; /* ie6 fix */
}
ul.menu li {
display:inline; /* line-up the list items horizontally */
padding:0; margin:0; /* again, reset browser defaults */
}
ul.menu li a {
padding:10px 20px;
background:#999;
color:#fff;
text-decoration:none;
display:block; /* block it baby! */
float:left; /* float each list item to the left */
}
ul.menu li a:hover {
background:#777;
}
If you enjoyed this post, you may want to subscribe via RSS or share this content with a friend using one of the icons below.
You may also find these similarly tagged posts interesting:
html, Tutorial
Our eCommerce storefront was in need of a professional online marketing strategy. Headway Marketing came up with a plan and executed every element of the plan. Today, we have a much larger online presence.
— Kelley M, KelleyFurniture.com
© 2004-2010 - Headway Marketing LLC - 851 Stone Canyon Dr., St. Louis, MO, 63021 - tel: (314) 266-9321 - fax: (314) 667-4106
Hooray! Thanks you very much for this. It works!
I’ll be back to post a link to my site once she’s live.
Thanks Again.