
If you’ve ever designed a sleek dark mode interface, you might have noticed something strange. You used the exact same font, size, and weight as your light theme, yet the text suddenly looks heavier, slightly blurry, or bloated.
Your eyes aren't playing tricks on you. This is a well-documented optical phenomenon, and it means your typography needs to lose a little weight when the lights go out.
Let’s dive into the science behind this visual illusion and explore how you can use modern CSS and variable fonts to keep your typography perfectly balanced in both light and dark modes.
This optical quirk is known as irradiation (or the irradiation illusion). First studied in depth by German physicist Hermann von Helmholtz in the 19th century, it describes how our brains perceive light areas on dark backgrounds.
Light-emitting pixels on a dark screen bleed outward into the surrounding dark pixels. Because our eyes are imperfect optical lenses, this glowing effect (often called halation) causes the white shapes of letters to physically look larger and thicker to our retinas than dark shapes of the exact same size on a light background.
The result? A font weight of 500 (Medium) that looks elegant and highly readable on a white background suddenly looks like a muddy 600 (Semibold) on a dark grey background. It reduces legibility, crowds counter spaces (the negative space inside letters like o, e, and a), and increases cognitive fatigue for your users.
To counter this illusion, the intuitive fix is to reduce the CSS font-weight. If your light mode uses font-weight: 500, you might try lowering it to font-weight: 400 in dark mode.
/* Traditional approach */
body {
font-weight: 500;
background-color: #ffffff;
color: #1a1a1a;
}
@media (prefers-color-scheme: dark) {
body {
font-weight: 400; /* Slimming down the font */
background-color: #121212;
color: #f5f5f5;
}
}
While this works, standard font weights have a major drawback: they change the physical bounding boxes of the letters.
When a typeface changes from Medium to Regular, the characters get narrower. On a text-heavy page, switching between light and dark mode will cause the text to reflow, shifting paragraphs, lines, and container heights. This triggers Cumulative Layout Shift (CLS), which harms both the user experience and your SEO performance.
This is where variable fonts save the day.
Many high-quality variable fonts include a custom axis called Grade (GRAD). Grade is specifically designed to adjust the optical weight (thickness) of a typeface without changing its physical width or layout metrics.
When you change the grade of a variable font, the letters get thinner or thicker, but the text takes up the exact same amount of horizontal space. Zero layout shift, 100% visual harmony.
If you are using a variable font that supports the Grade axis (such as Roboto Flex, Inter, or Heuristica), you can seamlessly adjust your typography for dark mode using the font-variation-settings property.
/* Base styles for light mode */
:root {
--bg-color: #ffffff;
--text-color: #1a1a1a;
--font-grade: 0; /* Standard optical weight */
}
/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
:root {
--bg-color: #121212;
--text-color: #f5f5f5;
--font-grade: -50; /* Slightly thinner grade for dark mode */
}
}
body {
background-color: var(--bg-color);
color: var(--text-color);
font-family: 'Inter Variable', sans-serif;
font-variation-settings: 'GRAD' var(--font-grade);
transition: background-color 0.3s, color 0.3s;
}
By dialing down the 'GRAD' setting to a negative value (typically between -20 and -100, depending on the typeface), you instantly neutralize the irradiation illusion. The text retains its perceived visual weight, rendering with identical clarity to its light-mode counterpart.
Because light text glows outward in dark mode, the spaces between the letters also appear smaller. This tight kerning can make text look cramped and hard to scan.
In addition to adjusting your font weight or grade, it is highly recommended to slightly increase the letter-spacing in your dark mode styles. A tiny fraction of an em is usually all it takes to restore breathing room to your body copy:
@media (prefers-color-scheme: dark) {
body {
letter-spacing: 0.01em; /* Subtle increase to counteract glow */
}
}
Great typography is invisible; it should never call attention to its own technical limitations.
By understanding the physiological quirks of how humans perceive light and dark, you can elevate your design system. Utilizing variable font grades and subtle letter-spacing adjustments ensures that your content remains incredibly crisp, beautifully balanced, and highly readable—no matter what theme your users prefer.
Photo by Efrem Efre on Pexels