HTMLTableCellElement: bgColor property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("HTML DOM")}}

The **HTMLTableCellElement.bgColor** property is used to set the background color of a cell or get the value of the obsolete [bgColor](/en-US/docs/Web/HTML/Reference/Elements/td#bgcolor) attribute, if present.

توجه: This property is deprecated and CSS should be used to set the background color. Use the {{cssxref("background-color")}} property instead.

Value

One of the following value types can be used:

  • a named color, like red or blue
  • a hex code, like #0000dd or #00d

توجه: The values accepted here are a limited subset of the CSS color values. Only {{cssxref("named-color")}} and 3- or 6-digit {{cssxref("hex-color")}} (with no alpha-channel). While all HTML color values are valid in CSS, this is not true in the other direction.

Examples

Use CSS background-color instead. An example of using [background-color with HTML table elements](/en-US/docs/Web/CSS/Reference/Properties/background-color#colorized_tables) is available on the {{cssxref("background-color")}} page.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("HTMLTableRowElement.bgColor")}}