There has been some discussion in the past about how/when to use tables in web development. Though, the conclusion is the same: when you’re dealing with tabular data, tables are absolutely required.
Designing a table is a challenge – and here I’m not talking only about the way it looks. It’s (mostly) about how easy is your table to read. If your table isn’t easy to scan, usually users get annoyed as they lose focus when trying to find the right column and row.
Having said that, today we’re going to create beautiful and practical tables styled using CSS3. Also, jQuery will be used to create fallbacks for older browsers.

What’s so cool about these tables?
In this article you’ll see how CSS3 and tables can work together to create some cool and usable results.
- Rounded corners with no images
- Very easy to update – there are no extra CSS id’s or classes added
- User-friendly and easy to read
Rounded table corners
Here’s the trick: while border-collapse‘s default value is separate, we need also to set the border-spacing to 0.
table {
*border-collapse: collapse; /* IE7 and lower */
border-spacing: 0;
}
For IE7 and lower, we need to add a specifically line, in order to create a good fallback for the tables.
Then, we just need to round some corners:
th:first-child {
-moz-border-radius: 6px 0 0 0;
-webkit-border-radius: 6px 0 0 0;
border-radius: 6px 0 0 0;
}
th:last-child {
-moz-border-radius: 0 6px 0 0;
-webkit-border-radius: 0 6px 0 0;
border-radius: 0 6px 0 0;
}
th:only-child{
-moz-border-radius: 6px 6px 0 0;
-webkit-border-radius: 6px 6px 0 0;
border-radius: 6px 6px 0 0;
}
jQuery hover fallback
You may already know that when it comes about IE6, :hover does not actually work on non-anchor elements.
So, to make it work, instead the CSS solution we’ve used:
.bordered tr:hover
{
background: #fbf8e9;
-o-transition: all 0.1s ease-in-out;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
you could use some jQuery code to simulate the hover effect:
$('.bordered tr').mouseover(function(){
$(this).addClass('highlight');
}).mouseout(function(){
$(this).removeClass('highlight');
});
and here’s also the styles for the CSS highlight class:
.highlight
{
background: #fbf8e9;
-o-transition: all 0.1s ease-in-out;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
The above is basically the .bordered tr:hover duplicate.
jQuery zebra fallback
To create the zebra effect, using CSS3, we’ve selected the even rows within the tbody:
.zebra tbody tr:nth-child(even) {
background: #f5f5f5;
-webkit-box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
-moz-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;
box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
}
Now, the above selector is a CSS3 one – so no support for older browsers. Below you’ll see how we may target and style the even rows for all browsers:
$(".zebra tbody tr:even").addClass('alternate');
A simple jQuery line.
.alternate {
background: #f5f5f5;
-webkit-box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
-moz-box-shadow:0 1px 0 rgba(255,255,255,.8) inset;
box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
}
The CSS class that will style the even rows.
Browser support
The tables already degrade very nice on older browsers, so it’s up to you if you want to use also the above jQuery solutions. It’s all about the visitors audience you’re targeting.

Conclusion
Do you like the CSS3 tables I made? Feel free to comment about the final result and thanks for reading this article!
Nice trick. learning again, thank you !
update
Great looking tables, but a few unanswered questions: Why do IE7 and below need border-collapse:collapse? And why does border-collapse:collapse prevent rounded corners on modern browsers?
Excellent bit of info, im sure you know though that IE8 doesn’t support rounded corners either. Although that said it works with IE8
ps – meaning your example works with IE8 im guessing thats the jquery fall back :)
it’s new science anymore :D
thank u ☺
Not used it yet but I’m lovin’ it already. I’m definitely going to use this on my project. Thanks for sharing.
nice result,
thanks
I already implemented the same without any help :) me genius though… Thanks for publishing :)
Beautiful! Thanks for sharing. Now i know what i’m doing tonight… the first example does it for me. :D
The article title is pretty misleading since most of the suggestions deal with highlighting with jQuery. Only CSS covered won’t work in anything but Moz or Webkit.
Ted, don’t forget that the demo works also on about modern browsers like Opera or IE9/IE10.
I’ve always set the border radius on the table itself and added the property overflow:hidden; to fix how it looks.
It works perfectly on webkit browsers but not on FireFox … Didn’t bother testing IE tbh :D
Your Zebra Stripe code example could be better. You have the selector in the CSS3 version defined as “.zebra tbody tr:nth-child(even)” and jQuery defined as “.zebra tr:even”. The truth is you should use the same selector method in CSS and in jQuery otherwise the result will look different.
The whole purpose of using jQuery to accomplish a task in older browsers is to bring the same result where support is lacking. jQuery brings a common DOM selection method to all browsers, old and new. Therefore, using a CSS3 selector of “.zebra tbody tr:nth-child(even) {…}” or a jQuery selector of “$(‘.zebra tbody tr:nth-child(even)’).addClass(…)” would have the same result.
To see what I mean about the CSS selectors being different try comparing them on a table that has a thead with rows, multiple tbody sections with multiple rows, and a tfoot with multiple rows.
Indeed, in case you have multiple thead/tfoot rows for your table, using this jQuery
$(".zebra tbody tr:even").addClass('alternate')line is a better approach.Thanks for adding this!
Just updated the jQuery selector.
I love this. Just one thing, if your table has just one column it seems to miss off the border on the top left corner. Is there any way to fix this?
Thanks, I’m glad you love it.
Regarding your request, I just updated the article using the CSS3
:only-childselector. Now, the above tables will look just fine when using only one column.That’s fixed it! Thanks for your quick response :)
hee verry good
vui
Excelente aporte de como crear estilos a tablas. esto nos ahorrara código.
It is also nice.. :P
read every post and watching all Demos…
all are awesome :)
The Boostrap CSS framework has this kind of rounded sexiness built into it.
very very nice Catalin Rosu.I am using this my own site :).Thanks once again.
I am trying to do something on round border with css property which link http://www.webinbangla.com/2012/05/css-round-shape/
I really start hating that IE stuff!
A job well done sir!
working great.. nice.. thanx a lot…
excellent solution for table design . thanks for this will implement and thanks for sharing such webdesign tips
Hi, I tried this tutorial, but only the top corners of my table are rounded. How can I round the bottom corners too? Thanks
When I implement this – I’m getting rounded corners on each and every cell within the table as well as rounded corners on the perimeter of the table. What might be causing the rounding of corners on indiviidual cells?
very good. thanks you
Thank you! I use to reset the collapse but for all browsers and I didn’t understand why it wasn’t showing the border radius in browsers… :)