[X]

Painting With document.bgColor

browser tricks 1996 partly

Repainting the page from script with document.bgColor, no CSS involved.

In 2026: Partly: document.bgColor and its friends fgColor, linkColor and vlinkColor predate both CSS and the DOM, and the HTML standard keeps them alive as obsolete but required. This demo is a complete document so no stylesheet overrides the attribute it sets, and the background really is being repainted by the relic.

Where it came from: JavaScript 1.0, Netscape 2, 1996, before CSS shipped anywhere. Kept obsolete but functional by the HTML standard.
MDN HTML standard

<html>
<head><title>bgColor</title></head>
<body>
<font face="Verdana" size="2"><b>The background you are watching is document.bgColor.</b>
There is no stylesheet in this frame. fgColor made this text white.</font>
<script language="JavaScript">
document.fgColor = "#FFFFFF";
var hues = ["#000040", "#400040", "#004040", "#404000", "#000000"];
var i = 0;
setInterval(function () {
  document.bgColor = hues[i = (i + 1) % hues.length];
}, 900);
</script>
</body>
</html>
sandboxed demo · breaks nothing but itselfrestart

More in browser tricks

all 30 in browser tricks › · the whole library ›