Two columns Three columns Mixed cols and rows Gallery Archives Clean & Clear Dark or Black High Contrast/ Impact Blog Designs New Corporate/ Professional Unconventional Designs Liquid layouts Web Design Firms Our Favorites What's Popular Last 20 submissions
Horizontal Menus Vertical Menus Multiple/ Nested Levels
CSS Compressor Image to Color Palette Tool

CSS Examples CSS horizontal Tabs

Date: 10/07/2004 CSS horizontal Tabs

Author: CSS Drive/ Based on Eric's Meyer's Tab.

A horizontal tab interface that's extremely lightweight and scalable. Each tab is simply a list element and set to "display: inline" to cause it to align side by side instead of vertically.

The HTML:

<ul id="tablist">
<li><a class="current" href="http://www.cssdrive.com">CSS Drive</a></li>
<li><a href="http://www.yahoo.com">Yahoo</a></li>
<li><a href="http://www.google.com">Google</a></li>
<li><a href="http://www.news.com">News.com</a></li>
</ul>

The CSS:

#tablist{
padding: 3px 0;
margin-left: 0;
margin-bottom: 0;
margin-top: 0.1em;
font: bold 12px Verdana;
border-bottom: 1px solid gray;
}

#tablist li{
list-style: none;
display: inline;
margin: 0;
}

#tablist li a{
text-decoration: none;
padding: 3px 0.5em;
margin-right: 3px;
border: 1px solid #778;
border-bottom: none;
background: white;
}

#tablist li a:link, #tablist li a:visited{
color: navy;
}

#tablist li a:hover{
color: black;
background: lightyellow;
border-color: navy;
}

#tablist li a.current{
background: lightyellow;
}

Comments (11)

This is a real nice script...even though i know how to do it, but it saves time if ur in a hurry.

#1: Asif Shahidullah on 10/24 at 10:21 AM

Perfect !!!!!!!!!!! I love it !
Simple and great ! Thanks !

#2: baz on 05/20 at 09:18 AM

nice... i`ll try it...

"skrip yg gue cari-cari selama ini"

#3: sweedia on 06/16 at 01:26 AM

Saved me a lot of time, much thanx

#4: sandro on 08/10 at 05:49 AM

modify this

#tablist li a.current{
border-bottom: 1px solid white;
background: lightyellow;
}
for remove border in current page

#5: SuggeElson on 09/16 at 05:06 AM

Simple and great ! Thanks !

#6: Xue peak on 08/27 at 01:44 AM

yes this works great and i am very happy to find this site with clean examples

#7: papercube on 09/07 at 02:10 PM

realy nice article, great site. thanks for informations

#8: instalki on 09/22 at 05:17 AM

Please check this code... I wanted 100% width tabs, this is not working good in different resolutions. If it works in 1024 x 768, it not working in IE with 1280 x 1024 resolution.

It will be great if you could give me the tutorial link for tabs as well as any example for shadowed ceter aligned CSS layout.

The problem is, middle container I want it as liquid. If only that was fixed and outer areas as liquid I wouldn't have faced these problems.

<!-- HTML Code -->
<div class="TabBar" >
<div class="indnavbarlink" > Hello Sir </div>
<div class="indnavbarlink" > Namma Bengaluru </div>
<div class="indnavbarlink" > hello </div>
<div class="indnavbarlink" > hello</div>
<div class="indnavbarlink" > hello </div>
<div class="indnavbarlink" > hello </div>
<div class="indnavbarlink" > hello </div>
</div>

/* CSS code */
.TabBar
{
display:table;
//display:block;
width:100%;
float:left;
padding:0px;
margin:0px;
height:36px;
clear:both;

}

.TabBar .indnavbarlink a
{
width:14.08%;
//width:14.1%;
border:1px solid #ffffff;
display:block;
font-family:Arial;
text-align:left;
font-size:12px;
color:#ffffff;
font-weight:bold;
text-decoration: none;
text-align:center;
padding-top:10px;
padding-bottom:10px;
padding-right:0px;
padding-left:0px;
margin:0px;
background-color:#ffa216;
float:left;
}

#9: rekha on 10/04 at 01:08 AM

REALY,REALY nice article

#10: Peter Mensen on 11/18 at 11:47 AM

CSS Forums

CSS Forums: latest threads Last Post Info
Tables or Div's? What's you opinion? (24) 07/04/2009 03:07 am
By: HannahLyn
IE6 vs. DIV height 100% (1) 07/03/2009 11:17 am
By: Emerson
Font doesn't diplay in Firefox? (10) 07/02/2009 03:27 am
By: spongebob
Help regarding horizontal menu lists (5) 07/02/2009 03:04 am
By: tenchin
how to make video resize when you click on it. (1) 07/01/2009 02:32 am
By: ted1067