Search code examples
htmlcsshtml-tablepadding

How to increase the distance between table columns in HTML?


Let's say I wanted to create a single-rowed table with 50 pixels in between each column, but 10 pixels padding on top and the bottom.

How would I do this in HTML/CSS?


Solution

  • There isn't any need for fake <td>s. Make use of border-spacing instead. Apply it like this:

    table {
      border-collapse: separate;
      border-spacing: 50px 0;
    }
    
    td {
      padding: 10px 0;
    }
    <table>
      <tr>
        <td>First Column</td>
        <td>Second Column</td>
        <td>Third Column</td>
      </tr>
    </table>

    See it in action.