Table border
To set the table border in CSS, use the border property.
The following example sets the blue border for table, TH, and TD:
table, TH, TD { border: 1px solid blue; }
Collapse border
The Border-collapse property sets whether the table border is collapsed to a single border:
Table { border-collapse:collapse; } table,th, TD { border: 1px solid black; }
Table Inner Margin
To control the distance between the contents of the table and the border, set the Padding property for the TD and TH elements:
TD { padding:15px; }
Alignment of table text
Text-align and Vertical-align properties set the alignment of text in a table
The Text-align property sets the horizontal alignment, such as left-aligned, right-aligned, or centered:
TD { text-align:right; }
The Vertical-align property sets vertical alignment, such as top, bottom, or center alignment:
TD { height:50px; vertical-align:bottom; }
Table Color
The following example sets the color of the border, as well as the text and background color of the th element:
table, TD, Th { border:1px solid green; } th { background-color:Green; color:white; }
9. CSS Table Style