CSS Clamp Generator
Generate CSS clamp() values.
About this tool
Enter a minimum size in pixels, a preferred size in viewport-width units and a maximum size in pixels, and copy the clamp() value. It joins your three numbers; it does not work out the viewport-based slope for you.
How to use
How it works
clamp(min, preferred, max) returns the preferred value, but never less than min or more than max. A vw preferred value scales with the window width: 4vw is 4% of the viewport width. For example, on a 600px-wide window 4vw is 24px.
Worked example
Fluid text between 12px and 24px
- Input
- min 12, preferred 4vw, max 24
- Output
- clamp(12px, 4vw, 24px)
- Walkthrough
- Below a 300px viewport the text stays 12px, above 600px it stays 24px, and in between it scales with the width.
Limitations
- The preferred value is vw only; calc() mixes with rem or a fixed offset are not generated.
- It does not solve for a preferred value between two breakpoints.
- Output is in px, which does not scale with user font-size settings; consider rem for text.
Questions
How does CSS clamp() work?
How do I make fluid typography with clamp?
Can I use rem instead of px?
Is clamp() widely supported?
Features
- min, preferred vw, max
- Copy-ready value
- Runs in your browser
Related resources
Guides and videos from around the web—opens on YouTube or the publisher’s site.
What Is A RESTful API?
Traversy Media
API context for JWT, JSON, and encoding utilities.
Watch on YouTubeHow base64 encoding works
Andrew Schmelyun
Mental model for Base64 encode/decode tools.
Watch on YouTube
- MDN Web Docs
MDN
Primary reference for web APIs these developer tools touch.
- Base64
MDN
When Base64 is appropriate versus raw binary transfer.