
Dark mode is no longer just a trendy preference—it is a user experience staple. For developers and designers, implementing dark mode is often treated as a simple color inversion: make the background dark, make the text light, and call it a day.
However, if you have ever looked at a dark-mode interface and felt your eyes straining, or noticed that the body text suddenly looked awkwardly bold and blurry, you have experienced the "dark side" of typography.
In this article, we’ll explore why typography behaves differently on dark backgrounds and how to optimize your web fonts for an exceptional dark-mode reading experience.
To understand why typography needs optimization in dark mode, we have to look at how human eyes perceive light.
When you display bright text on a dark background, light emitted from the characters spreads into the surrounding dark pixels on our screens (and onto our retinas). This physical phenomenon is known as the halation effect (or irradiation).
Because of halation:
To combat this, we must actively adjust our type scale, weights, and spacing when switching from light to dark mode.
Since halation artificially thickens white text, the most effective optimization is to slightly reduce your font weight when dark mode is active.
If your light mode body copy uses a weight of 400 (Regular), you should consider dropping it to 350 or 300 (Light) in dark mode.
This is where variable fonts shine. Instead of downloading a completely new static font file (which increases page load times), you can use a variable font and smoothly adjust the weight axis using CSS.
/* Base styles (Light Mode) */
body {
font-family: 'Inter Variable', sans-serif;
font-weight: 400;
background-color: #ffffff;
color: #1a1a1a;
}
/* Dark Mode Adjustments */
@media (prefers-color-scheme: dark) {
body {
background-color: #121212;
color: #e4e4e7;
/* Reduce weight slightly to compensate for halation */
font-weight: 360;
}
}
By dropping the weight from 400 to 360, the text maintains its visual hierarchy and readability without appearing overly aggressive.
Because light text bleeds outward, individual letterforms can visually merge together, causing legibility issues—especially at smaller body sizes.
To counteract this, slightly increase the letter-spacing (also known as tracking in typography terms) in dark mode. A tiny adjustment goes a long way:
@media (prefers-color-scheme: dark) {
p {
letter-spacing: 0.015em; /* A subtle boost to keep letters distinct */
}
}
By opening up the tracking, you preserve the distinct shape of each character, allowing the reader's eyes to glide across the text more naturally.
The human eye does not tolerate extreme contrasts well in low-light environments. Pure white text (#FFFFFF) on a pitch-black background (#000000) creates a harsh, vibrating contrast that causes immediate eye strain.
Instead, aim for a softer contrast ratio. Use off-whites, light grays, or desaturated pastels for your text, and deep grays or dark blues for your background.
#000000 with Text #FFFFFF#121212 with Text #E4E4E7 (or #F4F4F5)This subtle softening dramatically dampens the halation effect, making long-form reading much more comfortable.
Different browsers render text differently based on their subpixel rendering engines. Sometimes, web fonts in dark mode can look unpleasantly jagged.
While you should generally let the operating system handle font smoothing, applying the following CSS helper can sometimes clean up thin white text on dark backgrounds in macOS browsers:
@media (prefers-color-scheme: dark) {
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
}
Note: Use this property sparingly and test across multiple devices, as aggressive font smoothing can occasionally make text too thin on certain displays.
Before you ship your next dark mode stylesheet, run through this quick checklist:
font-weight of body text by roughly 30 to 50 units (ideal with variable fonts).letter-spacing (e.g., 0.01em to 0.02em).#000 and #FFF. Use dark grays for backgrounds and soft, cool grays for body text.By paying attention to these microscopic details, you will elevate your user interface from a simple "palette swap" to a deeply polished, comfortable, and accessible reading experience.
Photo by Ofspace LLC, Culture on Pexels