borderCollapse style property
Specifies or returns whether the borders of a table are joined in a single border or not.
This property only works for table elements. If you want to use collapsed borders, the cellSpacing property must be set to '0px'.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: border-collapse |
Possible values:
The type of this property is string.
One of the following values:
Borders are not drawn between table cell elements. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
Default. Separate borders are drawn for all table cell element. |
Default: separate.
Example HTML code 1:
This example illustrates the use of the border-collapse property:
|
||||
<head> <style> .collapsed { border-collapse: collapse; } .collapsed td { border: 1px solid blue; } .separated { border-collapse: separate; } .separated td { border: 1px solid blue; } </style> </head> <body> Table with collapsed border: <table class="collapsed"> <tr> <td>Apple</td> <td>13.46</td> </tr> <tr> <td>Pear</td> <td>35.21</td> </tr> <tr> <td>Peach</td> <td>23.12</td> </tr> </table> <br /><br /> Table with separated border: <table class="separated"> <tr> <td>Apple</td> <td>13.46</td> </tr> <tr> <td>Pear</td> <td>35.21</td> </tr> <tr> <td>Peach</td> <td>23.12</td> </tr> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the borderCollapse property in JavaScript:
|
||||
<head> <style> .example td { border: 1px solid blue; } </style> </head> <body> <table class="example" id="Table"> <tr> <td>Apple</td> <td>13.46</td> </tr> <tr> <td>Pear</td> <td>35.21</td> </tr> <tr> <td>Peach</td> <td>23.12</td> </tr> </table> <button onclick="Table.style.borderCollapse='separate'">border-collapse: separate</button> <button onclick="Table.style.borderCollapse='collapse'">border-collapse: collapse</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
CSSStyleDeclaration, htmlElement.currentStyle, htmlElement.runtimeStyle, htmlElement.style
HTML elements:
Related pages:
border
borderBottom
borderBottomColor
borderBottomStyle
borderBottomWidth
borderColor
borderLeft
borderLeftColor
borderLeftStyle
borderLeftWidth
borderRight
borderRightColor
borderRightStyle
borderRightWidth
borderSpacing
borderStyle
borderTop
borderTopColor
borderTopStyle
borderTopWidth
borderWidth
borderBottom
borderBottomColor
borderBottomStyle
borderBottomWidth
borderColor
borderLeft
borderLeftColor
borderLeftStyle
borderLeftWidth
borderRight
borderRightColor
borderRightStyle
borderRightWidth
borderSpacing
borderStyle
borderTop
borderTopColor
borderTopStyle
borderTopWidth
borderWidth
External links:
border-collapse (MSDN)
border-collapse (Mozilla Developer Center)
border-collapse (Safari Reference Library)
border-collapse (W3C)
border-collapse (Mozilla Developer Center)
border-collapse (Safari Reference Library)
border-collapse (W3C)
User Contributed Comments