CSS Property: border-collapse
[this page | pdf | back links]
The CSS (CSS2) border-collapse property indicates
whether table borders are collapsed into a single border or detached as in
standard HTML. Note if a !DOCTYPE is not specified then the border-collapse
property can produce unexpected results.
Valid property values (other
than inherit and initial) are:
Default Value:
|
separate
|
JavaScript syntax:
|
e.g. object.style.borderCollapse="collapse"
|
Inherited:
|
Yes
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,td {border: thin solid red}
table.x1 {border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr><td>1. Element with default property</td></tr>
<tr><td> </td></tr>
</table>
<br>
<table class="x1">
<tr><td>2. Element set using in-file HTML style</td></tr>
<tr><td> </td></tr>
</table>
<br>
<table id="x2">
<tr><td>3. Element set using JavaScript</td></tr>
<tr><td> </td></tr>
</table>
<script>
document.getElementById("x2").style.borderCollapse="collapse";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyBorderCollapse() {
var x = document.createElement("DIV"); x.style.borderCollapse = "collapse"; return (window.getComputedStyle(x, null).borderCollapse == "collapse");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties