CSS Tables
The looking of the HTML table can be greatly improved with CSS. You have already met a few properties that are commonly used with tables.
Table Borders
The border properties define the size and style of the border (located between the padding and the margin).
Example
Result
Notice that the table in the example above has double borders because both the table and the th or td elements have separateborders. For display a single border for the table use border-collapse property.
Collapse Tables
The border-collapse property sets the table borders are collapsed into single border or separated each.
Example
Result
Table Width and Height
Width and height of a table is defined by the width and height properties.
Example
Result
Table Text Alignment
The text alignment is used to align the text in the table by text-align and vertical-align properies.
The text-align property sets the horizontal alignment. Like left,right or center.
Example
Result
The vertical-align property sets the vertical alignment. Like top, bottom or middle.
Example
Result
Table Padding
Use the padding property to control the space between the border and content in a table on the td and th elements.
Example
Result
Table Color
The CSS background-color property permits you to color background of a table, row and cells.
The CSS color property permits you to color text of a table, row and cells.
Example
Result
Leave a comment
No Cmomments yet