Skip to content
techsnow

Responsive Design

CSS Units

UnitRelative toUse for
pxFixed pixelsBorders, shadows
%The parent's sizeWidths
remThe root font size (usually 16px)Font sizes, spacing
emThe element's own font sizePadding that scales with text
vw / vh1% of the screen width / heightFull-screen sections
dvh1% of the visible screen height on mobileFull-height layouts on phones
frA fraction of free space in a gridGrid columns
chThe width of the "0" characterReadable text width
html { font-size: 100%; }  /* 16px */
h1 { font-size: 2.5rem; }  /* 40px */
.hero { min-height: 80vh; }
article { max-width: 65ch; }

Fluid sizes with clamp()

h1 { font-size: clamp(2rem, 5vw, 4rem); }

The heading grows with the screen but never goes below 2rem or above 4rem.