I don't know why this bothers me so much, but when I create websites, I always try to do all my styling with CSS. However one thing I always have to remember to do when I'm working with tables is add cellspacing="0" and cellpadding="0"
Why is there not a CSS property to override these antiquated HTML 4 attributes?
For controlling "cellpadding" in CSS, you can simply use padding on table cells. E.g. for 10px of "cellpadding": td { padding: 10px; } For "cellspacing", you can apply the border-spacing CSS property to your table. E.g. for 10px of "cellspacing": table { border-spacing: 10px; border-collapse: separate; }
The cellspacing attribute was used to control the amount of space between cells of a table. This attribute has been deprecated, and if you want to add space between table cells you can do so with CSS.
While these features still work for backwards-compatibility reasons, and are often used in HTML email, the cellpadding and cellspacing attributes are now obsolete. In this instance, the cellspacing attribute is replaced by the border-collapse and border-spacing properties defined on the parent <table> element.
The cell padding is used to define the spaces between the cells and its border. If cell padding property is not apply then it will be set as default value.
Cellspacing :
table { border-collapse: collapse; }
As for cellpadding, you can do
table tr td, table tr th { padding: 0; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With