Borders around empty cells

Posted on 2011-10-26
Last Modified: 2012-05-12
Simple question I hope.

I have an HTML table. I'd like an empty cell to have no borders (except where it touches another cell). How do I do that?
Question by:skbohler
    LVL 42

    Accepted Solution

    That's what the empty-cells property of CSS is for:

    td {
      empty-cells: hide;

    Open in new window


    Author Comment

    Would this syntax work:

    <table border="1" cellspacing="0" cellpadding="5" width="400" style="empty-cells:hide">

    It's not working in the latest version of Firefox.
    LVL 42

    Expert Comment

    by:David S.
    No, the "empty-cells" property only applies to table-cells themselves, not the table they are in.

    Also it's best to avoid using the style attribute. While external stylesheets are best, you could also use an embedded stylesheet, like the following. (<style> elements may only appear inside the <head> element.)
    <style type="text/css">
    td {
      empty-cells: hide;

    Open in new window


    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    "I want to put my photos online, but I don't want them stolen.  What settings should I use?" When You Put Photos Online First and foremost, any digital file published on the WWW can be copied, stored, modified, retransmitted, etc.  Remember Naps…
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now