Make headings scale smoothly between a minimum size on phones and a maximum on large screens, with no breakpoints.
h1 {
font-size: clamp(2rem, 1.4rem + 3vw, 3.5rem);
line-height: 1.1;
}
h2 {
font-size: clamp(1.6rem, 1.2rem + 2vw, 2.5rem);
line-height: 1.15;
}
h3 {
font-size: clamp(1.3rem, 1.1rem + 1vw, 1.75rem);
line-height: 1.25;
}
Headings that look right on a laptop are often huge on phones, and themes fix that with a few fixed breakpoints. clamp() scales them smoothly with the screen width instead.
clamp(min, preferred, max) uses the preferred value but never goes below the minimum or above the maximum. The preferred value mixes a fixed rem part with a vw part, so the size grows with the window, and the rem part keeps it responding to the visitor’s browser text size.
.entry-content h2. Match its selectors if these rules don’t take effect.Open a post and slowly narrow the browser window. Headings should shrink smoothly rather than jumping at certain widths.