HTMLFontElement: color property

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

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

{{APIRef("HTML DOM")}}

The obsolete **HTMLFontElement.color** property is a string that reflects the [color](/en-US/docs/Web/HTML/Reference/Elements/font#color) HTML attribute, containing either a named color or a color specified in the hexadecimal #RRGGBB format.

The format of the string must follow one of the following HTML microsyntaxes (see {{cssxref("<color>")}}):

MicrosyntaxDescriptionExamples
Valid name color string_nameOfColor (case insensitive)_Green, green, GREEN
Valid hex color string_#RRGGBB_#008000
RGB using decimal values_rgb(x x x) (x in 0-255 range)_rgb(0 128 0)

Value

A string.

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

Examples

js
// Assumes there is <font id="f"> element in the HTML

const f = document.getElementById("f");
f.color = "green";

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • The {{domxref("HTMLFontElement")}} interface it belongs to.