HTMLTableElement: bgColor property

Deprecated

Avoid using this feature in new projects. Some table styling attributes have no effect. They are superseded by CSS. This feature may be a candidate for removal from web standards or browsers.

The bgcolor property of the HTMLTableElement represents the background color of the table.

Note: Do not use this attribute anymore. Instead, use the CSS background-color property by modifying the element's style attribute or using a style rule.

Value

A string representing a color value.

When set to the null value, that null value is converted to the empty string (""), so elt.bgColor = null is equivalent to elt.bgColor = "".

Examples

js
// Set table background color to lightblue
const t = document.getElementById("TableA");
t.bgColor = "lightblue";

Specifications

Specification
HTML
# dom-table-bgcolor

Browser compatibility

See also