background-color: ***;

Browser
  • IE
  • Cr
  • Sf
  • Fx
  • O

The background-color property specifies the background color of an element.

The background color of the cells can be specified by applying this property to the TABLE, TR, TD or TH elements.


table {
background-color: #bde9ba;
}

Property Value Explanation
background-color color code or name the color of the background

The default is "transparent".

The display examples

When you apply this property to the TABLE element.

table { background-color: #bde9ba; }

Cell A Cell B
Cell C Cell D

When you apply this property to the TR element.

tr.example { background-color: #bde9ba; }

Cell A Cell B
Cell C Cell D

When you apply this property to the TD (TH) element.

td.example { background-color: #bde9ba; }

Cell A Cell B
Cell C Cell D

Example


<html>
<head>
<title>TAG index</title>

<style type="text/css">

table, th, td {
border: 2px #2b2b2b solid;
color: #2b2b2b;
}

table { background-color: #bde9ba; }
th { background-color: #ffd78c; }

</style>

</head>
<body>

<table>
<tr>
<th>Heading A</th>
<th>Heading B</th>
<th>Heading C</th>
</tr>
<tr>
<td>Cell A</td>
<td>Cell B</td>
<td>Cell C</td>
</tr>
<tr>
<td>Cell D</td>
<td>Cell E</td>
<td>Cell F</td>
</tr>
</table>

</body>
</html>

Output
Heading A Heading B Heading C
Cell A Cell B Cell C
Cell D Cell E Cell F