You are here: Reference > HTML > attributes > bgColor (col, colgroup)

bgColor attribute (col, colgroup)

Browser support:
Sets the background color of one or more specified columns in a table element.
This attribute is deprecated. Use the background-color style property instead.
JavaScript page for this attribute: bgColor. You can find other example(s) there.

Possible values:

A legal color value. It can be a hexadecimal, RGB or predefined color value. For more information, see the page for colors.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the bgColor attribute:
<table border="1px">
    <col bgcolor="red" />
    <tr>
        <td>Apple</td>
        <td>Pear</td>
        <td>Peach</td>
    </tr>
    <tr>
        <td>red</td>
        <td>green</td>
        <td>yellow</td>
    </tr>
</table>
Did you find this example helpful? yes no

Example HTML code 2:

Recommendation:
<table border="1px">
    <col style="background-color: #ff0000;" />
    <tr>
        <td>Apple</td>
        <td>Pear</td>
        <td>Peach</td>
    </tr>
    <tr>
        <td>red</td>
        <td>green</td>
        <td>yellow</td>
    </tr>
</table>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content