CSS Remove Spacing Between Table Cells

You may be wondering why even if you set the margins of the td elements in a table to 0px a space still appears around them. You can remove this spacing by using: table {border-collapse: collapse;}

One thought on “CSS Remove Spacing Between Table Cells

  1. Sure, but in addition you need to specifically remove the borders from tr and td elements – the whole solution being:

    table
    {
    border-collapse:collapse;
    }
    tr,td
    {
    padding:0;
    }

    When you then need to re-instate some space between particular cells, add the following into that cell’s CSS:

    .spaced_cell
    {
    margin-bottom:1px solid black;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>