Background Colors - HTML

In previous versions of HTML, you could use the bgcolor attribute in the <table>, and <tr>, <th>, and <td> tags to set a color background for the element. This attribute has been deprecated in HTML 4.01 in favor of using styles to set the background color of table elements. Using the deprecated method, you can set the background of a header row to yellow with code similar to the following:

<tr bgcolor=“yellow”>
<th>H Resolution</th>
<th>V Resolution</th>
<th>Frequency</th>
</tr>

Using CSS to accomplish the same effect would resemble the following code.

<tr style=“background-color: yellow;”>
<th>H Resolution</th>
<th>V Resolution</th>
<th>Frequency</th>
</tr>

However, not all user agents adequately support background colors in tables. Older browsers are particularly finicky about correctly representing background colors. When in doubt, test.

Use the background-color CSS property to control table element backgrounds.

Use the background-color CSS property to control table element backgrounds.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML Topics