Absolute
px
border-width: 1px;A CSS pixel is a reference unit, not necessarily one hardware pixel.
CSS reference
Compare common relative and absolute CSS units and choose values that respond to text and viewport changes.
8 of 8 entries
Absolute
border-width: 1px;A CSS pixel is a reference unit, not necessarily one hardware pixel.
Font-relative
padding: 1.5rem;Relative to the root font size.
Font-relative
font-size: 1.1em; padding: .75em;For font-size, em uses the parent font size; for most other properties, the element’s own font size.
Font-relative
max-width: 65ch;Based on the advance width of the zero glyph; it is not an exact character count.
Context-relative
width: 80%;The reference quantity depends on the property and layout context.
Viewport
width: 90vw; min-height: 100vh;One unit is one percent of viewport width or height; mobile browser UI can affect visible space.
Viewport
min-height: 100svh;
height: 100dvh;svh uses the small viewport; dvh tracks the dynamic viewport and can change as browser UI moves.
Grid
grid-template-columns: 1fr 2fr;Distributes fractions of available space in Grid; it is not a general length unit.