Border-collapse properties for overlapping cell borders in a CSS table

Source: Internet
Author: User

Syntax: border-collapse:separate | Collapse

Value:
Separate: Default value. Border Independent (standard HTML)
Collapse: Adjacent edges are merged

Description
Sets or retrieves whether the edges of a table's rows and cells are merged or separated by a standard HTML style.
This property is read-only for Currentstyle objects. Readable and writable for other objects.
The corresponding script attribute is bordercollapse.

Example:

Table {border-collapse:separate;}

Apply to:
ie5.0+ currentstyle Runtimestyle Style TABLE


Example one: Useless style

The following is a reference fragment:

<table width= "border=" 1 "cellpadding=" 0 "cellspacing=" 0 "bordercolor=" #FF0000 ">   <tr>     < td>&nbsp;</td>     <td>&nbsp;</td>     <td>&nbsp;</td>     <td >&nbsp;</td>   </tr>   <tr>     <td>&nbsp;</td>     <td> &nbsp;</td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr >   <tr>     <td>&nbsp;</td>     <td>&nbsp;</td>     <td> &nbsp;</td>     <td>&nbsp;</td>   </tr></table>



Example two: function style

The following is a reference fragment:

<table width= "border=" 1 "cellpadding=" 0 "cellspacing=" 0 "bordercolor=" #FF0000 "style=" Border-collapse: Collapse; " >   <tr>     <td>&nbsp;</td>     <td>&nbsp;</td>     <td> &nbsp;</td>     <td>&nbsp;</td>   </tr>   <tr>     <td>& nbsp;</td>     <td>&nbsp;</td>     <td>&nbsp;</td>     <td>& nbsp;</td>   </tr>   <tr>     <td>&nbsp;</td>     <td>& nbsp;</td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr> </table>


Table Width=1 has set the width to 1.
The problem we face is that each TD edge is a 1px,table edge and 1px. So when the two TD next to each other, because each TD edge is 1, so when the edge of the "width and" is 1+1=2. When TD and Table are adjacent, the same.

Collapse: Adjacent edges are merged

Adjacent edges are merged! I used to say that 1+1=2 is the problem between TD and TD, the adjacent side between TD and Table. By default, adjacent edges are not merged, so this is 1+1=2. Now we're using border-collapse:collapse to merge us, so the width is still 1px. That is, a thin border appears.

CellSpacing is set to "0", and the result is that the distance between each cell in the first table is 0. If you set the table border to "0", the cell distance is 0.
The CellPadding property is used to specify the size of the white space between the cell contents and the cell boundaries
。 The parameter value of this property is also a number that represents the pixel count of the height of the white space distance between the cell contents and the upper and lower bounds, and the width of the white space between the cell contents and the left and right boundaries.

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.