A Web Design Community curated by Chris Coyier

#61: Basic Table Styling with CSS

By: Chris Coyier on: 4/22/2009 with 37 Comments

Tables are great. They are perfectly suited for use on the web. That is, for displaying tabular data! In this screencast we’ll cover what that actually means, take a look at a table, the markup that creates it, quirks and things-you-should-know. Then we start styling it up with CSS and quickly touch on some jQuery bonus stuff at the end.

Links from Video:

Running Time: 41:17

Direct Download: High Quality, Quicktime .M4V Format (AppleTV Ready)

37 Responses

  1. Mghmg says:

    nice tutorial

    thanks a lot very useful

  2. Harald says:

    Great screencast. Was interessting event thou I knew some of the stuff but I learnd a lot of new stuff too. Kinda didn’t understand the css tables stuff earlier, but you cleared that up nicley. Really like the jquery stuff. Looking forward to the next screencast. :o)

  3. Art Webb says:

    You so read my mind. I am working on a project now that screams for a table.

    Thanks.
    @webb_art

  4. Ian says:

    Very useful screencast. Nice and concise.

    One thing I would have done differently, would be to use text where you have the ‘tick’ and ‘exclamation marks’, then use CSS image replacement to replace the words with the images – probably by using a span around the text. Seems a bit more semantic than relying on the alt tag to me, but I’m not sure how search engines/screen readers would see these techniques differently.

    <td><span class="yes">Yes</span></td>

    • Yep definitely, that would be a good way to go! In addition, the icons should be a CSS sprite not inline images that need to load a zillion times (instead of once).

  5. Drum says:

    Great tutorial tnx!

  6. Snookerman says:

    Thanks Chris, just what I wanted. I can’t believe I requested this just four days ago, you are quick! I just need to watch it but I’m sure it’s awesome, heheh..

  7. jay says:

    I with Ian. Safari has a bad habit of not displaying alt tags on small images when images are disabled anyway. Not that using sprites always solves this, just have to get creative on markup.

  8. Hey Chris, instead of using jQuery for the row highlighting, couldn’t you do something like tr:hover td { background: red; }? Or is this not cross-browser reliable?

    • Yes you absolutely could do that, that would be the ideal way, it’s just dumb IE doesn’t do hovers on anything but anchor links. The jQuery method is just safer.

  9. Navdeep says:

    Very nice tutorial Chris.

    @3drockz

  10. Al says:

    does not dislay as well in IE7 as FF2

  11. savagecorp says:

    i can’t wait to see an advanced table screen-cast !!!

  12. Vasili says:

    I hate when you get those little things that mess up the code (like the callback in jQuery). I’ve thought myself, especially when working with jQuery, to check to make sure that the event handler is closed.

    Just wondering, what microphone are you using?

  13. Kevin says:

    Thanks Chris, that specificy tangent solved hours of grief!!! I didn’t know that a parent with an id’s styles overrode a child’s classes.

  14. Very cool! I think it’s very important to have a good looking table

  15. Jussi says:

    Thanks Chris, nice stuff once again from you. I really love the way you are doing stuff, not too much editing out if everything is not working as intended.

    Laughing maybe abit too hard on some of your comments (watching these normally quite late), have to hope neighbors are not too mad at me :)

    Jussi from Finland.

  16. Jarod says:

    Cool. I’ll have to check this out tomorrow if I get some downtime at the office.

  17. Fred says:

    A good videocast Chris, enjoyed it and learnt a couple of bits, cheers.

  18. Ariyo says:

    Very Nice Chris. Thanks! I learned a lot. I can’t wait for the advance screencast.

  19. Jim Zak says:

    Hey Chris, yet again, another great instructional video :) Just finished up my html/xhtml class at my local C.C. they covered css and intro to javascript. But still don’t cover what the kewl techniques that you cover so I still continue to learn a lot from you. Love the jQuery stuff too.

    I am always recommending to my class mates to check out your site so they can learn some kewl stuff from you.

    Keep up the great work and as usual, I’m always looking forward to your emails with the newest video tutorials etc… from CSS-Tricks.

    Thanks a Billion,

    ~Jim Zak~

  20. z0r says:

    Chris, you are amazing!
    Found you with the help of wpcandy and webtuts and you are the person who helped me to understand the CSS basics (and further). Thx alot ! Cheers from Russia!

  21. nkrstevski says:

    You can style different columns without giving classes to separate cells – just go out and search for colgroup/col tags combination to achieve this effect (like here: link)

  22. Nyte says:

    Hey Chris,

    I really like your video’s (only seen a few, but plan to watch them all). I found this website at the start of my internship at a web-development company and this website helped me a lot with the assignments I get (i’m a total newbie when it comes to CSS).

    Also, you’re little troubleshootings are quite interesting as well. I learned where to look at when I screw something up myself!

  23. Jon Thomas says:

    I like your tone. Nice vid. Not drab and boring like some. U cracked me up a bit.

  24. Aleksander says:

    I love your tutorials! This one was very helpfull to me;)
    Your voice is a bit low sometimes.

    Could you do more tutorials on jQuery and AJAX in jQuery? I’m working on a site and want to use AJAX and jQuery on it, but i don’t manage it too well by this date;)

    Regards from Norway;)

  25. tommyalf says:

    Very nice tutorial Chris but i believe that it is not complete. I can look only about 75%. I’m fall in mistake? thank’s tommyalf (tommyalf.blogspot.com)

    • Aleksander says:

      The movie is complete. I watched the whole movie. And at the end he say “ok, thanks bye” or something like that;)

      Try SHIFT + F5

  26. rob says:

    I was yelling at the screen when you had that image problem, you couldn’t hear me though.

  27. Web4YOU says:

    Great stuff, very useful I love it! Keep up to good work.

  28. Johnb says:

    I was a bit disappointed to see you add classes to table cells in order to highlight a column. I’m not a Table master, but even i knew about the col and colgroup tags! :)

    The book “pro css and html design patterns” by Michael Bowers, Apress explains how browsers calculate column widths. There’s a lot more to it than you think! It’s very interesting but quite complex. I forget how it works just minutes after reading. :)

  29. Hey Chris, this was the second Screencast I watched (after Episode 41 – WP as a CMS) and I am really amazed. I created step by step a table with your help and it looks great.

    Thanks for your help! :)

  30. Lee Floyd says:

    No good examples of why CSS table styles are useful?
    I would say the best example is equal-height columns.

    Forget backgrounds for faux-columns or any other technique, all you need is to set display:table, display:table-row, and display:table-cell as described in the screencast. The only problem is IE6 doesn’t support it.

This comment thread is closed. If you have important information to share, you can always contact me.

* This website may or may not contain any actual CSS or Tricks.