Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>The title of the document</title> <style> table, td, th { border: 1px solid #ccc; } thead { background-color: #1c87c9; color: #ffffff; } th { height: 30px; text-align: center; } td { padding: 3px 10px; } #table1 { border-collapse: separate; border-spacing: 10px; } #table2 { border-collapse: collapse; border-spacing: 10px; } </style> </head> <body> <h1>Border-collapse property example</h1> <h2>border-collapse: separate;</h2> <p>When using the "border-collapse: separate", the border-spacing property can be used to define the space between the cells.</p> <table id="table1"> <thead> <tr> <th>Heading</th> <th>Heading</th> <th>Heading</th> <th>Heading</th> </tr> </thead> <tbody> <tr> <td>Some text</td> <td>Some text</td> <td>Some text</td> <td>Some text</td> </tr> <tr> <td>Some text</td> <td>Some text</td> <td>Some text</td> <td>Some text</td> </tr> </tbody> </table> <h2>border-collapse: collapse;</h2> <p>When using the "border-collapse: collapse", the border-spacing property has no effect.</p> <table id="table2"> <thead> <tr> <th>Heading</th> <th>Heading</th> <th>Heading</th> <th>Heading</th> </tr> </thead> <tbody> <tr> <td>Some text</td> <td>Some text</td> <td>Some text</td> <td>Some text</td> </tr> <tr> <td>Some text</td> <td>Some text</td> <td>Some text</td> <td>Some text</td> </tr> </tbody> </table> </body> </html>