Course offer · HLD · LLD · System Design at ₹799 until 30 Nov (not interview packs)

CSS Studio

Interactive Learning

On this tool

em compounds with nested font-size. rem always looks at the root. Mixing them without a plan makes padding mysterious.

Units & Sizing

CSS Units & Fluid Sizing

Fixed pixels are easy to start with and brittle on real screens. This playground lines up px, %, em, rem, vw, vh, dvh, ch, and clamp(min, preferred, max) so you can see relative sizing move when the root font-size or viewport changes. Drag the frame, nudge html font-size, and watch which bars stay put. Prefer rem for type scale, %, fr, and clamp for fluid layouts, and reserve raw px for hairlines and borders.

What people get wrong

em compounds with nested font-size. rem always looks at the root. Mixing them without a plan makes padding mysterious.

Should I use rem or em?
Use rem for a consistent scale tied to the root. Use em when you want padding or gaps to grow with the element’s own font-size.

Root & viewport

16px
720px
420px

clamp()

12px
4vw
32px
Generated CSS
From the controls
Loading editor…

Drag the corner to resize. Root font-size is 16px.

px
32px
%
50%
em
2em
rem
2rem
vw
20vw
vh
10vh
dvh
10dvh
ch
24ch
clamp()
clamp(12px, 4vw, 32px)