Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are cellspacing and cellpadding not CSS styles

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?

like image 302
Ryan Smith Avatar asked Dec 03 '08 23:12

Ryan Smith


People also ask

What is cellpadding and Cellspacing in CSS?

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; }

Is Cellspacing deprecated?

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.

Is cellpadding deprecated?

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.

What is CSS cellpadding?

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.


1 Answers

Cellspacing :

table { border-collapse: collapse; } 

As for cellpadding, you can do

table tr td, table tr th { padding: 0; } 
like image 157
mat Avatar answered Sep 21 '22 21:09

mat