Styling Tables – Cellpadding & Cellspacing in CSS
Posted on March 29th, 2014.
One of my first questions when I started learn CSS was how replace cellpadding and cellspacing table’s attributes to separate the styling from the HTML.
The equivalent properties in CSS is padding and border-spacing. However the padding property is applied in the TD tag, not to the TABLE tag.
For example, to achieve the same effect as <table cellpadding="0" cellspacing="0">
you should use the following:
table {
border-spacing: 0;
}
table td {
padding: 0;
}
Or, to have an equivalent to <table cellpadding="2" cellspacing="1">
you should use:
table {
border-spacing: 1px;
}
table td {
padding: 2px;
}
Source: http://www.frontpagewebmaster.com/m-269102/tm.htm (dead link)