Snippets / Typography /

Fluid Typography

Smoothly scale font size between a minimum and maximum with clamp() — no breakpoints, no media queries.

Fluid Heading

font-size: clamp(1rem, 2.5vw + 0.5rem, 2.5rem)
Widely Supported
typographyno-js

Quick implementation

.fluid-typography-demo {
  font-size: clamp(1rem, 2.5vw + 0.5rem, 2.5rem);
}

Prompt this to your LLM

Includes role, constraints, two framework variants, and edge cases to handle.

Act as a senior CSS developer. Create a fluid typography snippet that scales a heading smoothly between a minimum and maximum size using the clamp() function. Do not use media queries. Provide the CSS for a class named .fluid-typography-demo. Include a comment explaining the formula: font-size: clamp(1rem, 2.5vw + 0.5rem, 2.5rem). Ensure the code is production-ready and accessible.

Why this matters in 2026

Fluid typography eliminates the need for multiple media queries. It ensures text remains readable across all device widths without jarring jumps. This approach simplifies maintenance and improves the user experience on variable screen sizes.

The logic

The clamp() function sets a minimum, preferred, and maximum value. The preferred value uses viewport units to scale dynamically between the bounds. This creates a smooth curve instead of stepped breakpoints.

Accessibility & performance

Respecting user font size preferences is critical for accessibility. Ensure contrast ratios remain valid as text scales up or down. Performance is excellent since it requires no JavaScript or media query recalculations.