Tab menu using lists and CSS

Filed under: CSS Stylesheets

Here’s a simple way of creating a tab menu using unordered lists and CSS.

First you will need your menu items in a list, preferably unordered, but ordered will work as well. Give the list an id, for example, “tabmenu”.

<ul id="tabmenu">
<li>menu 1</li>
<li>menu 2</li>
<li>menu 3</li>
</ul>

Next, define your tabmenu id either in the head section of your html or in an external CSS stylesheet. You will need to set the display to inline, the list-style-type as none and padding on the right to about 20px.

#tabmenu li {
display: inline;
list-style-type: none;
padding-right: 20px;
}

Here’s what the above example looks like:

  • menu 1
  • menu 2
  • menu 3
divider

One Comment to “Tab menu using lists and CSS”

  1. Jamie Says:

    The other way to achieve a tabbed menu using html lists is to use float:left on the li.


    #tabmenu li {
    float:left;
    }

    By using float:left, you preserve the block display of <li> which is useful for defining width and height.

    display:inline doesn’t allow width and height to be defined.

Leave a Comment