CSS tips: web design about cellspacing and cellpadding

Source: Internet
Author: User
Tags expression
css| Skills | design | Web page | cellpadding and cellpadding of web design forms we often clear the default styles in the following ways:
<table cellspacing= "0" cellpadding= "0" ></table>
Many friends would say that performance in the structure, so does not conform to the standard, then how to take this performance out, some friends may be confused. We can use the Border-collapse:collapse property of table to replace cellspacing= "0" with TH,TD padding:0; property to replace the cellpadding= "0".
Table {
Border-collapse:collapse;
border-spacing:0;
}

TH,TD {
padding:0;
}

You can also use expression to implement the style of cellpadding= "0":
Table {
Border-collapse:collapse;
border-spacing:0;
Padd:expression (this.cellpadding=0);
}
Here's a look at the descriptions of these two attributes in the HTML and CSS Primer (7th edition) Book:
you can not only use the Style property for table settings. For example, you can use the cellpadding and CellSpacing properties to control the spacing of table borders. The CellSpacing property sets the spacing (in pixels) between table borders and table cells, and the CellPadding property sets the spacing (in pixels) around the information in the cell. Setting the CellPadding property to 0 will make all the information in the table as close to the table border as possible, even to the border. The cellpadding and CellSpacing properties allow you to fully control the appearance of the table.

Note: Although the cellpadding and cellspacing properties are still allowed in XHTML, there are style attributes padding and border-spacing that are equivalent to the two properties in the CSS. However, the current Web browser's support for these style properties is inconsistent, so it is recommended that you still use property cellpadding and cellspacing to adjust the spacing of the tables.


And in "Proficient in CSS" book, the author advocates the method is:
Table {
Border-collapse:collapse;
}

<table cellpadding= "0" ></table>
As to which method is good, friends consider their own discretion.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.