ā¤ Like
šŸ”– Save
šŸ”— Share
@thedevspaceio
@thedevspaceio

CSS Units Cheatsheet

@thedevspaceio

šŸ“ CSS Units Cheatsheet

CSS units define how sizes, distances, and durations are measured. Choosing the right unit makes layouts responsive, accessible, and maintainable across devices.

āœ… Absolute units āœ… Relative units āœ… Viewport units āœ… Container query units āœ… Character units āœ… Flexible units āœ… Angle units āœ… Time units āœ… Frequency units āœ… Resolution units āœ… Modern fluid sizing

#css #units #responsive #viewport #rem #em #clamp #containerqueries #flexbox #grid


Absolute units

UnitDescription
pxDevice pixels (logical). Use for precise control, but combine with relative units for responsiveness.
ptPrint-focused point unit; rarely used for web layout.
pcPicas; 1pc = 12pt. Print-focused.
cmCentimeters; print-focused.
mmMillimeters; print-focused.
qQuarter-millimeters; 1q = 0.25mm. Print-focused.
inInches; print-focused.

Relative units

UnitDescription
emRelative to the element's font-size. Useful for component-relative sizing.
remRelative to the root (html) font-size. Great for global scaling.
%Relative to the parent property (width, height, etc.). Context-dependent.
capRelative to the height of a capital letter.
icRelative to the width of a CJK ideographic character.
lhRelative to the element's line-height.
rlhRelative to the root element's line-height.
exRelative to the x-height of the font.

Viewport units

UnitDescription
vw1% of viewport width. Useful for full-viewport sections.
vh1% of viewport height.
vmin1% of the smaller viewport dimension.
vmax1% of the larger viewport dimension.
vi1% of viewport inline size.
vb1% of viewport block size.
svw1% of small viewport width.
svh1% of small viewport height.
svmin1% of the smaller small-viewport dimension.
svmax1% of the larger small-viewport dimension.
lvw1% of large viewport width.
lvh1% of large viewport height.
lvmin1% of the smaller large-viewport dimension.
lvmax1% of the larger large-viewport dimension.
dvw1% of dynamic viewport width.
dvh1% of dynamic viewport height.
dvmin1% of the smaller dynamic-viewport dimension.
dvmax1% of the larger dynamic-viewport dimension.

Container query units

UnitDescription
cqw1% of the container's width.
cqh1% of the container's height.
cqi1% of the container's inline size.
cqb1% of the container's block size.
cqmin1% of the smaller container dimension.
cqmax1% of the larger container dimension.

Character units

UnitDescription
chWidth of the 0 (zero) character. Helpful for monospace width approximations.
exx-height of the font. Less consistent across fonts.

Flexible units

UnitDescription
frFractional unit used in CSS Grid to allocate remaining space.

Angle units

UnitDescription
degDegrees.
radRadians.
gradGradians.
turnFull turns.

Time units

UnitDescription
sSeconds.
msMilliseconds; 1s = 1000ms.

Full-Stack AI Developer Roadmap

From HTML & CSS to working with AI models, all in one structured roadmap.

@thedevspaceio
www.thedevspace.io