What is the CSS Lengths Reference?
Visual reference for all CSS length units — px, rem, em, vh, vw, dvh, svh, ch, ex, and more. Compare units side by side.
Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.
Using the CSS Lengths Reference
Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.
Browse unit categories
Units are grouped: absolute (px, pt, cm), font-relative (rem, em, ch, ex), viewport (vw, vh, dvh, svh, lvh), and container (cqw, cqh).
See live comparisons
Each unit is shown with a live-sized element demonstrating the computed value at your current viewport size.
Click to copy
Click any unit name to copy a CSS usage example.
What the generated code looks like
Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.
/* Absolute units */
.box-px { width: 200px; } /* 200 physical pixels */
.box-pt { width: 150pt; } /* 150 points (1pt = 1.333px) */
/* Relative to font size */
.box-rem { width: 12.5rem; } /* 12.5 x root font-size (usually 200px) */
.box-em { width: 12.5em; } /* 12.5 x current element's font-size */
.box-ch { width: 60ch; } /* 60 x width of "0" in current font */
/* Relative to viewport */
.box-vw { width: 50vw; } /* 50% of viewport width */
.box-dvh { height: 100dvh; } /* 100% of dynamic viewport height (mobile-safe) */
.box-svh { height: 100svh; } /* 100% of smallest viewport height */Use dvh (dynamic viewport height) instead of vh on mobile. 100vh includes the browser chrome on iOS, causing overflow. 100dvh adjusts as the browser chrome shows/hides.
Pro tips for better results
dvh replaces vh for full-height mobile layouts
On iOS Safari, 100vh includes the address bar height. The page overflows until the user scrolls. 100dvh is the correct unit for full-height mobile layouts since iOS 15.4 and Chrome 108.
ch units are ideal for prose line length
max-width: 65ch limits text containers to 65 characters wide — the optimal reading line length. ch is the width of the "0" character in the current font, giving typographically-correct line lengths.
Frequently asked questions
From the blog
Read more →Modern CSS techniques every developer should know
A practical tour of the CSS features that replaced yesterday’s hacks.
From design to code without the friction
How visual generators speed up the build without sacrificing clean output.
Writing CSS that scales with your project
Tokens, naming, and structure that keep large stylesheets maintainable.