
Have you ever spent hours perfecting the typography for a light UI, only to toggle on dark mode and feel like your text suddenly gained ten pounds?
You check your CSS stylesheet. The font family is identical. The font-weight property is still set to 400. Yet, light text on a dark background unmistakably looks heavier, chunkier, and tighter than dark text on a light background.
This isn't a browser rendering engine bug. It is a biological quirk of human vision known as the Irradiation Illusion—and understanding it is key to building polished, accessible dark mode interfaces.
First described by scientist Hermann von Helmholtz in the 19th century, the irradiation illusion causes bright areas to visually bleed into adjacent dark areas.
When your retina receives bright light against a dark backdrop (such as white text on a dark charcoal screen), the light receptors in your eyes overstimulate and blur slightly outward. This "halation effect" causes light-colored characters to physically glow outward into the surrounding darkness, making letter strokes appear 5% to 10% thicker than they actually are.
Conversely, when dark text sits on a bright background, the glowing white light surrounding the letters pinches the dark stroke inward, making black text appear visually thinner.
When typography visually expands in dark mode, several structural issues occur:
400 (Regular) and 600 (Semi-Bold) narrows, making body copy blur into headings.Fortunately, modern CSS gives us fine-grained control to compensate for this optical illusion.
If you are using static web fonts (e.g., standard WOFF2 files offering only rigid weights like 400 and 700), you cannot easily adjust font thickness. However, Variable Fonts allow you to set custom numeric weights along a continuous axis.
Instead of using 400 in both modes, reduce your body font weight slightly in dark mode—typically by 30 to 50 weight units.
:root {
--font-weight-body: 400;
}
[data-theme="dark"] {
/* Drop the weight slightly to counteract the optical glow */
--font-weight-body: 360;
}
body {
font-weight: var(--font-weight-body);
}
Because light letterforms bleed outward into the dark background, letter spacing needs room to breathe. Adding a tiny amount of letter-spacing counteracts the visual crowding.
[data-theme="dark"] body {
letter-spacing: 0.015em;
}
The intensity of the irradiation illusion depends directly on contrast ratio extremes. Pure white #FFFFFF text on pure black #000000 causes maximum halation, leading to harsh eye strain.
Soften the contrast by opting for dark slate backgrounds combined with off-white or light gray text.
/* Hard contrast (causes heavy text halation) */
.bad-dark-mode {
background-color: #000000;
color: #ffffff;
}
/* Soft contrast (reduces optical blooming) */
.good-dark-mode {
background-color: #0f172a; /* Dark Slate */
color: #e2e8f0; /* Soft Off-White */
}
Here is a clean, scalable CSS setup that balances typography across both light and dark themes using CSS custom properties and media queries:
:root {
--bg-color: #ffffff;
--text-color: #1e293b;
--font-weight-regular: 400;
--font-weight-bold: 600;
--letter-spacing-base: normal;
}
@media (prefers-color-scheme: dark) {
:root {
--bg-color: #0f172a;
--text-color: #e2e8f0;
/* Reduce weight by ~40 units */
--font-weight-regular: 360;
--font-weight-bold: 560;
/* Increase spacing slightly */
--letter-spacing-base: 0.012em;
}
}
body {
background-color: var(--bg-color);
color: var(--text-color);
font-weight: var(--font-weight-regular);
letter-spacing: var(--letter-spacing-base);
transition: background-color 0.3s ease, color 0.3s ease;
}
h1, h2, h3 {
font-weight: var(--font-weight-bold);
}
Designing effective dark interfaces isn't as simple as swapping background and foreground colors. True dark mode craftsmanship accounts for optical physics and biological visual perception. By trimming your variable font weights down by 30–50 units and slightly opening up letter spacing, your dark mode UI will feel just as balanced, crisp, and readable as your light mode design.
Photo by Brett Sayles on Pexels