CSS cellspacing equivalent


In HTML, there used to be a handy attribute on the table called “cellspacing”. The CSS equivalent of this is “border-spacing” property. I’m going to use inline CSS via the style tag for this example:

New CSS Version:

<table style="border-spacing: 0px;">
    <tr>
        <td>First Name</td>
        <td>Last Name</td>
    </tr>
</table>

Old HTML Version:

<table cellspacing="0">
    <tr>
        <td>First Name</td>
        <td>Last Name</td>
    </tr>
</tr>

Side note: If you’re looking for replacements for old cellpadding attributes you’ll want to look at the CSS “padding” property on the various elements.

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.