HTML Change Table Background Color

The bgcolor attribute change the background color of table and it can be also used to change the color of specific row(s) and column(s) of table. The default background color of table is white and can be changed using the bgcolor attribute or CSS background-color property.

HTML code example to change the background color of table, rows and columns using the bgcolor attribute.

<html>
<head>
<title>
</title>
</head>
<body>
<table bgcolor="purple">
<tr>
<td>
Table background Color Applied on this row and column
</td>
</tr>
<tr bgcolor="yellow">
<td>
Row with yellow color
</td>
<td>
Row with yellow color
</td>
</tr>
<tr>
<td bgcolor="pink">
Cell with pink color
</td>
<td bgcolor="orange">
Row with yellow color
</td>
</tr>
</body>
</html>

Save the file “filename.htm” and open it in browser to view the result as shown below.

image

HTML code example to change the background color of table, rows and columns using the CSS background-color property attribute.

<html>
<head>
<title>
</title>
</head>
<body>
<table style="background-color:purple">
<tr>
<td>
Table background Color Applied on this row and column
</td>
</tr>
<tr style="background-color:yellow">
<td>
Row with yellow color
</td>
<td>
Row with yellow color
</td>
</tr>
<tr>
<td style="background-color:pink">
Cell with pink color
</td>
<td style="background-color:orange">
Row with orange color
</td>
</tr>
</body>
</html>

Save the file “filename.htm” and open it in browser to view the result as shown below.

image

Tags: , , , , , ,

Author: Revo

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *

12 − four =

 

Pin It on Pinterest

Shares
Share This