coderef

Document colorsLimited availability

A document's bgColor, fgColor, alinkColor, linkColor, and vlinkColor properties get and set the background, foreground, active link, link, and visited link colors of that document.

Not yet supported in all major browsers — check the table and provide a fallback.

Discouraged: Document color attributes are superseded by CSS. Use instead: background-color, Color, CSS object model, getComputedStyle()

Browser support

DesktopChrome
1–63Not supported
64+Supportedsince Jan 23, 2018
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–68Not supported
69+Supportedsince Sep 3, 2019
Current: 157
Safari
1–10.1Not supported
11+Supportedsince Sep 19, 2017
Current: 27
MobileChrome Android
18–63Not supported
64+Supportedsince Jan 23, 2018
Current: 155
Firefox Android
4–68Not supported
79+Supportedsince Jul 28, 2020
Current: 157
Safari iOS
1–10.3Not supported
11+Supportedsince Sep 19, 2017
Current: 27

How to use

Support is still inconsistent across browsers. Use feature detection and test carefully.

Example

Full syntax and examples are on MDN: alinkColor.

Feature detection

JS · check before using
if ("Document" in globalThis && "alinkColor" in Document.prototype) {
  // Document.alinkColor is available
}

Sub-features

Support for each part of the feature (5). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Document.alinkColor64126911647911
Document.bgColor64126911647911
Document.fgColor64126911647911
Document.linkColor64126911647911
Document.vlinkColor64126911647911