Organizing content was always an important task for web designers. Just like accordions, using a CSS3 tabbed navigation can help you structuring similar groups of content.
Along with so many rounded corners (which lately became the default), today you’ll learn how to create some good looking CSS3 tabs with beveled corners. We’ll do that using a clever CSS3 gradients technique.

There are a lot of articles in the wild that show you how to create tabs with CSS3 and jQuery. Yet, I decided to create my own CSS3 tabs as well and I hope you’ll like my result.
The idea
A while ago I read this wonderful article by Lea Verou about how to create beveled corners using CSS3 gradients. I found that very clever and we will use that technique in order to create our tabs.
The HTML
The purpose here, as usual, is to write clean and semantic markup: unordered list for the tabbed navigation and simple div‘s for wrapping content.
So, check the HTML below:
<ul id="tabs">
<li><a href="#" title="tab1">One</a></li>
<li><a href="#" title="tab2">Two</a></li>
<li><a href="#" title="tab3">Three</a></li>
<li><a href="#" title="tab4">Four</a></li>
</ul>
<div id="content">
<div id="tab1">One - content</div>
<div id="tab2">Two - content</div>
<div id="tab3">Three - content</div>
<div id="tab4">Four - content</div>
</div>
The CSS
Minimal and easy to update styles, also no images were used here:
#tabs
{
overflow: auto;
width: 100%;
list-style: none;
margin: 0;
padding: 0;
}
#tabs li
{
margin: 0;
padding: 0;
float: left;
}
#tabs a
{
-moz-box-shadow: -4px 0 0 rgba(0, 0, 0, .2);
-webkit-box-shadow: -4px 0 0 rgba(0, 0, 0, .2);
box-shadow: -4px 0 0 rgba(0, 0, 0, .2);
background: #ad1c1c;
background: -moz-linear-gradient(220deg, transparent 10px, #ad1c1c 10px);
background: -webkit-linear-gradient(220deg, transparent 10px, #ad1c1c 10px);
background: -ms-linear-gradient(220deg, transparent 10px, #ad1c1c 10px);
background: -o-linear-gradient(220deg, transparent 10px, #ad1c1c 10px);
background: linear-gradient(220deg, transparent 10px, #ad1c1c 10px);
text-shadow: 0 1px 0 rgba(0,0,0,.5);
color: #fff;
float: left;
font: bold 12px/35px 'Lucida sans', Arial, Helvetica;
height: 35px;
padding: 0 30px;
text-decoration: none;
}
#tabs a:hover
{
background: #c93434;
background: -moz-linear-gradient(220deg, transparent 10px, #c93434 10px);
background: -webkit-linear-gradient(220deg, transparent 10px, #c93434 10px);
background: -ms-linear-gradient(220deg, transparent 10px, #c93434 10px);
background: -o-linear-gradient(220deg, transparent 10px, #c93434 10px);
background: linear-gradient(220deg, transparent 10px, #c93434 10px);
}
#tabs a:focus
{
outline: 0;
}
#tabs #current a
{
background: #fff;
background: -moz-linear-gradient(220deg, transparent 10px, #fff 10px);
background: -webkit-linear-gradient(220deg, transparent 10px, #fff 10px);
background: -ms-linear-gradient(220deg, transparent 10px, #fff 10px);
background: -o-linear-gradient(220deg, transparent 10px, #fff 10px);
background: linear-gradient(220deg, transparent 10px, #fff 10px);
text-shadow: none;
color: #333;
}
#content
{
background-color: #fff;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ddd));
background-image: -webkit-linear-gradient(top, #fff, #ddd);
background-image: -moz-linear-gradient(top, #fff, #ddd);
background-image: -ms-linear-gradient(top, #fff, #ddd);
background-image: -o-linear-gradient(top, #fff, #ddd);
background-image: linear-gradient(top, #fff, #ddd);
-moz-border-radius: 0 2px 2px 2px;
-webkit-border-radius: 0 2px 2px 2px;
border-radius: 0 2px 2px 2px;
-moz-box-shadow: 0 2px 2px #000, 0 -1px 0 #fff inset;
-webkit-box-shadow: 0 2px 2px #000, 0 -1px 0 #fff inset;
box-shadow: 0 2px 2px #000, 0 -1px 0 #fff inset;
padding: 30px;
}
/* Remove the rule below if you want the content to be "organic" */
#content div
{
height: 220px;
}
The jQuery
The code below it may not be the best possible, but I think it’s pretty decent :)
$(document).ready(function() {
$("#content div").hide(); // Initially hide all content
$("#tabs li:first").attr("id","current"); // Activate first tab
$("#content div:first").fadeIn(); // Show first tab content
$('#tabs a').click(function(e) {
e.preventDefault();
$("#content div").hide(); //Hide all content
$("#tabs li").attr("id",""); //Reset id's
$(this).parent().attr("id","current"); // Activate this
$('#' + $(this).attr('title')).fadeIn(); // Show content for current tab
});
})();
The result
Check out the transparent corners! You can use the tabs with any background image. No side effects, no overlapping colors to match or something else.
Also, the left shadow helps creating the effect of overlapping tabs.
Browser support
If you read my previous articles, then you already know that I like to do stuff that works (even if it just degrades gracefully) also on older browsers like the IE (Trident).
Having said that, this demo is working also for older browsers. Obviously, it just look slightly different, as no CSS3 support is available:

Such a gradient for Safari (lower than 5.1) would be quite complex. So, I decided to skip it (for now).
That’s it!
I hope you enjoyed this article and if you have questions, comments, or suggestions, let me know! Thanks for reading.

Hi,
Nice to see you’re using my technique. Keep in mind that Safari 5.1 supports the standard CSS gradient syntax, like Chrome. So it would work in Safari 5.1.
Hi Lea, thanks for the heads up.
Apparently, when I wrote this, I tested on Safari 5.05 as I didn’t had the Safari 5.1 installed. Anyway, the fact that latest Safari supports new gradient syntax is good news.
Nice idea but it is impossible for the white tab which is on the top to receive a shadow from the red tab to its right which is behind the white tab. The white tab should always be creating a shadow and not receiving one.
Just a small suggestion. On my system, none of the browsers that support gradient backgrounds do any sort of anti-aliasing on the color transitions, resulting in jaggies on the chamfer. Replacing “220deg” with “225deg” everywhere it appears greatly improves the appearance.
Also, having given the matter the thoughtful deliberation it deserves, I have decided that “Jaggies on the Chamfer” would not make a good name for a rock band.
Doug, I also noticed that replacing 220deg with 225deg improves the rendering on some browsers. Good point!
When you match a tab color with the background of a page it means that the tab and page are on top of the other pages and their tabs. This simply reflects how tabs work in the real world. If you want to separate the tab color from the page color then you can stack them any way you want and it might work. However, it is not wise to contradict our visual experience in the physical world when using a design that is modeled on the physical world.
Good tutorial, so I learned a lot of technical, I intend to write him into my Chinese blog.I have been learning on your site, hope to have more updated articles.thank you very much,Red!
it’s one brand new for tabs look…so good
thanks^^
Header designs and its color and effect are so good …. i will sure use it …
hi.
This tutorials are great. Do you know how I can link the left menu to each tab if its possible. Thanks and keep up the good work.
Thanks Felix, I’m glad you like my articles.
Regarding your question, I think you just need to style the
<ul id="tabs">tab list vertically to look like your left menu. In this way you’ll solve your problem.A few years ago I’d have to pay someone for this inromfation.
hey I found or created an issue for myself according to the js when this is executed : $(“#content div”).hide(); //Hide all content
any div that are within the content also hide so that ways i cant do some tihng like this :
One – img
One – text blabh
any workaround to that ??
help will be greatly appreciated.
great stuff by the way so much to learn here :)
Add a class to the wrappers div’s like
<div class="wrapper">and then just use:This should do it!
Thanks that did it .. although in the mean while i had started using the section tag instead of div .. but yeah thank again ..
But I think there is still some issue as becuse of this :
$(“#content div”).hide(); // Initially hide all content
$(“#tabs li:first”).attr(“id”,”current”); // Activate first tab
$(“#content div:first”).fadeIn(); // Show first tab content
even if i change this to
$(“#content .warpper”).hide(); // Initially hide all content
then then any div inside the tab 1 acs strangely i think because “current” is added to that too, this is my guess or some thing .. so my question is
will only adding this .warpper is enough or should some other changes made to this too ?
you must change the line:
$(“#content div:first”).fadeIn(); // Show first tab content
to
$(“#content .warpper:first”).fadeIn();
I think, this will work for you!
Good luck Akshay…
seems you have much practice on CSS3. :)
Great work Red Team, keep it up….
Hi..
first..i wanna to say this is great tutorial..
second.. i want to ask.. can CSS3 tabs makes it possible to use a mulitple tabs??
thanks.. i much learn from your site.. :)
This CSS works great with the YUI tabset as well. The only change you need to make (because of the skin.css) us to remove the 0.5em right margin from the li.
.yui-nav li
{
margin:0px !important;
}
Hi!
Please explain how can make auto scroll for these tabs?
Can you be more specific please?
Yeaa! I made this.
Now, these tabs are scrolled auto
$(document).ready(function() {
$(“#content>div”).hide(); // Initially hide all content
$(“#tabs li:eq(1)”).attr(“id”,”current”); // Activate first tab
$(“#content>div:eq(1)”).fadeIn(); // Show first tab content
$(‘#tabs a’).click(function(e) {
e.preventDefault();
$(“#content>div”).hide(); //Hide all content
$(“#tabs li”).attr(“id”,”"); //Reset id’s
$(this).parent().attr(“id”,”current”); // Activate this
$(‘#’ + $(this).attr(‘title’)).fadeIn(‘slow’); // Show content for current tab
});
setInterval(function()
{
curTab = $(‘#tabs li[id="current"]‘);
tabLength = $(‘#tabs li’).length;
curTabIndex = $(‘#tabs li’).index(curTab);
if(curTabIndex==tabLength-1){curTabIndex = 0;}
else {curTabIndex = curTabIndex+1;}
$(‘.tlinks #tabs>li>a’).eq(curTabIndex).click();
}, 7000);
});
at first : thanks ..:)
How i have content that be page of another URL . for example My content be another page.in fact will be display preview from another page..thank you