MaraHTML
Coding resources, tutorials and more.
CSS Tables
Share this page:
Basic table styling
Many of these properties have been dealt with in other CSS tutorials, particularly the boxes tutorial, so I wouldn't go into too much detail here with them.
table {border: 1px dashed;}
th, td {padding: 5px; width: 20px; height: 20px;}
th {border-bottom: 2px solid black; background-color: #FFC3FF;}
td {text-align: center;}
th, td {padding: 5px; width: 20px; height: 20px;}
th {border-bottom: 2px solid black; background-color: #FFC3FF;}
td {text-align: center;}
| 1 | 2 |
|---|---|
| 3 | 4 |
Borders on empty cells
If you've empty cells then you can use the empty-cell property to specify whether or not the border should show.
table {empty-cells: show;}
table {empty-cells:hide;}
| 1 | 2 |
| 3 |
table {empty-cells:hide;}
| 1 | 2 |
| 3 |
Gaps between cells
By default browsers usually leave a small gap between cells. This gap can be increased or decreased with the border-spacing property.
table {border-spacing: 5px 15px;}
| 1 | 2 |
| 3 | 4 |
In order to get rid of 'double-borders' between cells, and get the cells to collapse together, you can use the border-collapse property.
table {border-collapse:collapse;}
| 1 | 2 |
| 3 | 4 |
Notice: Undefined variable: admin1 in C:\wamp\www\inc\views\frontend_footer.php on line 2
Ads added by hosting provider.
Notice: Undefined variable: id1 in C:\wamp\www\inc\views\template_footer_start.php on line 2
Deprecated: mysql_query(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\inc\views\template_footer_start.php on line 2
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\inc\views\template_footer_start.php on line 3
Notice: Undefined variable: notifications2 in C:\wamp\www\inc\views\template_footer_start.php on line 6