Media queries make text jump between sizes. clamp() lets it grow smoothly instead.
The syntax
h1 {
font-size: clamp(34px, 5.2vw, 54px);
}
Read it as: never smaller than 34px, never larger than 54px, and 5.2% of the viewport width in between.
Pick the middle value
Choose the width where the size should reach its maximum. For 54px at 1040px wide:
54 / 1040 * 100 = 5.2vw
Keep it accessible
A pure vw value ignores the reader's zoom setting. Mixing in rem fixes that:
h1 {
font-size: clamp(2.125rem, 1.5rem + 3vw, 3.375rem);
}
Now the heading still scales with the screen, and it also grows when someone zooms the page.
