# Fluid Typography

> Headings and body text that scale smoothly with their container using clamp(), with no breakpoints.

- Category: [CSS Text Effects](https://copy-css.com/category/text)
- Tags: clamp, responsive, font-size, container units, scale
- Live preview: https://copy-css.com/snippets/fluid-typography
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<article class="fluid-type">
  <h2>Fluid type</h2>
  <p>Sizes scale smoothly with the container, between a set minimum and maximum.</p>
</article>
```

## CSS

```css
/* cqi follows the container width. Swap it for vw to follow the viewport. */
.fluid-type {
  container-type: inline-size;
  color: #0f172a;
  font-family: system-ui, sans-serif;
}

.fluid-type h2 {
  margin: 0 0 0.4em;
  font-size: clamp(1.5rem, 0.9rem + 6cqi, 3rem);
  line-height: 1.1;
}

.fluid-type p {
  margin: 0;
  color: #475569;
  font-size: clamp(0.875rem, 0.8rem + 1cqi, 1.125rem);
  line-height: 1.5;
}
```

## Notes

- This CSS Fluid Typography is 19 lines of pure CSS (0.4 KB) with no JavaScript and no dependencies. It uses container queries.
- container queries: Chrome 105+, Safari 16+, Firefox 110+.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
