How to use the css unit converter
- Enter a value and its unit.
- Set the root font size, the parent font size and the viewport if they differ from the defaults.
- Copy any converted value.
- For fluid type, enter the smallest and largest size and the viewport range, then copy the clamp() line.
The units
- rem: relative to the root (html) font size, 16px by default.
- em: relative to the parent’s font size, so it compounds when nested.
- pt: a print unit; 1pt is 1/72 inch, which CSS defines as 1.333px.
- vw / vh: 1% of the viewport’s width or height.
How the clamp() value is calculated
A fluid size is a straight line between two points: the smallest size at the smallest viewport and the largest size at the largest. The slope is (max size − min size) ÷ (max viewport − min viewport), written as vw, and the intercept is the remaining rem value. clamp() keeps the result between the two sizes outside that range. Mixing rem into the middle term keeps the text zoomable.
Questions
How do I convert px to rem?
Divide by the root font size. With the default 16px, 24px is 1.5rem.
Is clamp() safe to use?
Yes. All current browsers support it. Keep a rem part in the middle value so users can still zoom text.