The cellpadding and cellpadding of the table are often used to clear the default style as follows:
<Table cellspacing = "0" cellpadding = "0"> </table>
Many friends may say that the performance is in the structure and does not conform to the standards. Some may be confused about how to take out the performance. We can use the border-collapse: collapse; attribute of table to replace cellspacing = "0", and the padding: 0 attribute of th and td to replace cellpadding = "0 ".
The code is as follows: |
Copy code |
Table { Border-collapse: collapse; Border-spacing: 0; } Th, td { Padding: 0; }
|
You can also use expression to implement the cellpadding = "0" style:
The code is as follows: |
Copy code |
Table { Border-collapse: collapse; Border-spacing: 0; Padd: expression (this. cellPadding = 0 ); }
|
Next, let's take a look at the description of these two attributes in the book "Getting Started with HTML and CSS (version 7th:
The style attribute can be used for table settings. For example, you can use the cellpadding and cellspacing attributes to control the padding of table borders. The cellspacing attribute sets the spacing (in pixels) between table borders and table cells. The cellpadding attribute sets the spacing (in pixels) between information in cells ). If the cellpadding attribute is set to 0, all information in the table is as close as possible to the table border, or even to the border. The cellpadding and cellspacing attributes allow you to fully control the appearance of a table.
Note: Although the cellpadding and cellspacing attributes are still allowed in XHTML, the style attributes padding and border-spacing that are equivalent to these two attributes exist in CSS. However, the current web browser does not support these style attributes, so we recommend that you still use the attributes cellpadding and cellspacing to adjust the table spacing.
In the book "proficient in CSS", the author advocates the following methods:
The code is as follows: |
Copy code |
Table { Border-collapse: collapse; } <Table cellpadding = "0"> </table>
|
As to which method is best, friends may decide on their own.