CSS

adplus-dvertising
Working with tables in CSS
Previous Home Next

Creating Table Borders:

For specify table borders in CSS, we use the border property.

table, th, td
{
border: 1px solid black
;
}

Collapse Borders:

For border-collapse property sets whether the table borders are collapsed into a single border or separated.

table
{
border-collapse:collapse;
}
table,th, td
{
border: 1px solid black
;
}

Table Width and Height:

For adjusting Width and height of a table is defined by the width and height properties.

table
{
width:100%;
}
th
{
height:50px;
}

Table Text Alignment:

The text in a table is aligned with the text-align and vertical-align properties. The text-align property sets the horizontal alignment, like left, right, or center.

td
{
text-align:right;
}

Table Padding:

For control the space between the border and content in a table, we use the padding property on td and th elements.

td
{
padding:15px;
}

Table Color:

Following example specifies the color of the borders, and the text and background color of th elements.

table, td, th
{
border:1px solid green
;
}
th
{
background-color:green;
color:white;
}
Previous Home Next