plain-site › night mode

Night mode without CSS

Theme for this page

This page has a dark mode, and it contains no colour at all. One line in the <head> does it:

<meta name="color-scheme" content="light dark">

It tells the browser that the page is fine with either scheme. The browser then follows the operating system: a dark background, light text, light links, and dark form controls and scrollbars, all from the browser's own palette. The switch above only changes that content attribute. It writes one HTML attribute and nothing else, and it remembers your choice in localStorage.

A link ・ marked text ・ ・ ・


■ The one trade-off

Colours you set yourself do not adapt. A <font color="navy"> that is readable on white is invisible on the dark background, and a bgcolor="#eeeeee" table row turns into a bright stripe under light text. So every site makes one choice:

System paletteFixed palette
How<meta name="color-scheme" content="light dark">, no colour attributesbgcolor, text, <font color>; no color-scheme meta
Dark modefree, automaticnone, or a hand-written switch (below)
Colour you may uselinks, <mark>, <meter>, form controls (they adapt)anything
Looks likea documenta 1998 home page

■ See it: the meta tag in a frame

Here the meta tag says dark only, so the frame is dark whatever your system says. Change it to light. Then add <font color="navy"> around the text and switch back to see the trade-off.


■ A fixed palette with its own switch

If the site uses fixed colours, the night version is a second fixed palette, swapped with document.bgColor and friends. Those properties write the <body> attributes, so it is still all HTML. Each palette is one object.


■ The browser's own toolbar: theme-color

<meta name="theme-color" content="#1d1f21"> tints the browser's toolbar and address bar on Android, in Safari, and in installed web apps. It is one more colour that needs no CSS.


▲ top ・ plain-site ・ previous: museum ・ next: probe