HTML DOM
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
styleattribute 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
// Set table background color to lightblue
const t = document.getElementById("TableA");
t.bgColor = "lightblue";
Specifications
Browser compatibility
See also
- background-color
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
