Rounded Corner Tab Menu Using CSS

One of my readers recently asked me how can you add a tab based navigation to a Wordpress blog, using the wp_list_categories template tag. So I though I should create this quick tutorial, just in case there are other people looking for the same answer. (this article from rubiqube)

In this Wordpress tutorial I will implement the HTML/CSS required to create a category based main navigation, using some nice rounded corner tabs:

The rounded corner tabs


Since I will use the Douglas Bowman’s sliding doors technique, we will need 4 images, 2 for each state (normal, active). I named the images tableft, tabright and tableft_active, tabright_active. The images that will go on the right need to be wide enough, in order to accommodate the longest possible caption.

The HTML and CSS

Since this is a tab navigation, in most of the cases the HTML will go into header.php. The wp_list_categories template tag outputs a series of list items (li), one for each category item. All you need to do is place the PHP code between ul tags, like so:

  1. <ul id=“navtabs”>
  2. <?php wp_list_categories(‘title_li=’); ?>
  3. </ul>

Notice how the ul tag also has an id (navtabs). This will make it easier to style the menu using CSS:

  1. #navtabs {
  2. list-style: none;
  3. padding: 0;
  4. height: 30px;
  5. font-size: 11px;
  6. font-weight: bold;
  7. text-transform: uppercase;
  8. border-bottom: 4px solid #0288D8;
  9. }
  10. #navtabs li {
  11. float: left;
  12. background: #CCE7F7 url(images/tableft.png) no-repeat left top;
  13. padding: 8px 0 8px 14px;
  14. margin-right: 1px;
  15. }
  16. #navtabs li a {
  17. background: #CCE7F7 url(images/tabright.png) no-repeat top right;
  18. padding: 8px 14px 8px 0;
  19. }
  20. #navtabs li.current-cat {
  21. background: #0288D8 url(images/tableft_active.png) no-repeat left top;
  22. }
  23. #navtabs li.current-cat a {
  24. background: #0288D8 url(images/tabright_active.png) no-repeat right top;
  25. color: #FFFFFF;
  26. }

Leave a Reply