Absolute Units: px pt cm
Learn when to use fixed absolute units like pixels, points, and centimeters.
Absolute vs Relative Units
CSS units fall into two categories: absolute (fixed, real-world measurements) and relative (scale relative to something else). Absolute units are device-independent physical measurements.
px — Pixels
The pixel (px) is the most used absolute unit on screens. On standard displays 1px = 1 device pixel. On high-DPI (Retina) screens CSS pixels map to multiple device pixels, keeping elements the same visual size.
.button {
padding: 10px 20px;
border-radius: 4px;
border: 1px solid #ccc;
}All lessons in this course
- Absolute Units: px pt cm
- Relative Units: em and rem
- Viewport Units: vw vh dvh
- Min Max and Clamp Functions