CSS Reference Cheat Sheet
The numbers that come up constantly in front-end work — unit conversions, color values, breakpoints, aspect ratios, contrast thresholds, and viewport units — collected on one page instead of six different tabs. Every section links to the matching calculator for a live conversion, and to a full guide for the reasoning behind the numbers.
Px, rem & em conversion
At the browser default 16px root font-size. The em column assumes a 16px parent — with a different parent, divide the px value by that parent's size instead.
| px | rem | em (at 16px parent) |
|---|---|---|
| 8px | 0.5rem | at 16px parent: 0.5em |
| 10px | 0.625rem | at 16px parent: 0.625em |
| 12px | 0.75rem | at 16px parent: 0.75em |
| 14px | 0.875rem | at 16px parent: 0.875em |
| 16px | 1rem | at 16px parent: 1em |
| 18px | 1.125rem | at 16px parent: 1.125em |
| 20px | 1.25rem | at 16px parent: 1.25em |
| 24px | 1.5rem | at 16px parent: 1.5em |
| 28px | 1.75rem | at 16px parent: 1.75em |
| 32px | 2rem | at 16px parent: 2em |
| 36px | 2.25rem | at 16px parent: 2.25em |
| 40px | 2.5rem | at 16px parent: 2.5em |
| 48px | 3rem | at 16px parent: 3em |
| 56px | 3.5rem | at 16px parent: 3.5em |
| 64px | 4rem | at 16px parent: 4em |
| 72px | 4.5rem | at 16px parent: 4.5em |
| 96px | 6rem | at 16px parent: 6em |
Non-default root font-size, or need the reverse conversion? Use the px, rem & em converter — full reasoning in the px vs rem vs em guide.
Color: hex alpha & HSL hue wheel
An 8-digit hex color's last pair sets its alpha (transparency). A quick reference for the values that come up most:
| Hex pair | Decimal | Opacity |
|---|---|---|
ff | 255 | 100% |
e6 | 230 | ~90% |
cc | 204 | ~80% |
bf | 191 | 75% |
99 | 153 | 60% |
80 | 128 | ~50% |
66 | 102 | 40% |
4d | 77 | ~30% |
33 | 51 | 20% |
1a | 26 | ~10% |
00 | 0 | 0% |
HSL's hue is a position on the color wheel (0–360°) — saturation and lightness then adjust vividness and darkness independently of hue:
| Hue | Approximate color |
|---|---|
0° | Red |
30° | Orange |
60° | Yellow |
90° | Chartreuse |
120° | Green |
150° | Spring green |
180° | Cyan |
210° | Azure |
240° | Blue |
262° | Violet (this site's accent) |
300° | Magenta |
330° | Rose |
Convert a real value in all three formats with the hex, RGB & HSL converter — full comparison in the hex vs RGB vs HSL guide.
Common responsive breakpoints
Real device widths worth testing against, rather than arbitrary round numbers:
| Width | Typical device class | Notes |
|---|---|---|
320px | Small phone | iPhone SE and similarly narrow devices — the safe floor for a min-width test |
375px | Standard phone | iPhone 12–15 class widths; the most common mobile test width |
428px | Large phone | Larger iPhone Pro Max / Android phablet widths |
600px | Small tablet / large phone landscape | A common first "tablet-ish" media query step |
768px | Tablet portrait | iPad portrait; classic Bootstrap "md" breakpoint |
1024px | Tablet landscape / small laptop | iPad landscape; common sidebar-collapse point |
1280px | Laptop | A frequent "desktop" fluid-scale upper bound |
1440px | Desktop | Common full-HD-ish desktop width |
1920px | Large desktop | Full HD monitor width; a reasonable max-width ceiling |
Check what a vw/vh value resolves to at any of these with the viewport units calculator.
Common aspect ratios
| Ratio | Decimal | Typical use |
|---|---|---|
1 / 1 | 1.0 | Avatars, square thumbnails, icon tiles |
4 / 3 | 1.33 | Older photo/video standard, some product shots |
3 / 2 | 1.5 | DSLR photography default |
16 / 10 | 1.6 | Some laptop/monitor screens |
16 / 9 | 1.78 | Widescreen video embeds (YouTube, Vimeo) |
21 / 9 | 2.33 | Ultrawide hero banners, cinematic crops |
9 / 16 | 0.5625 | Vertical video (Stories/Reels/Shorts style embeds) |
1.618 / 1 | 1.618 | Golden ratio, occasionally used for hero imagery |
Reduce an arbitrary resolution to its simplest ratio with the aspect ratio calculator — full guide to the CSS aspect-ratio property.
WCAG contrast thresholds
| Level | Text size | Minimum ratio |
|---|---|---|
| AA | Normal text | 4.5:1 |
| AA | Large text (≥24px, or ≥18.66px bold) | 3:1 |
| AA | UI components / graphics (1.4.11) | 3:1 |
| AAA | Normal text | 7:1 |
| AAA | Large text | 4.5:1 |
Check a real pair with the WCAG contrast ratio checker — the luminance formula and worked examples are in the WCAG contrast guide.
Viewport units
| Unit | Meaning |
|---|---|
vw | 1% of viewport width |
vh | 1% of viewport height |
vmin | 1% of whichever is smaller — width or height |
vmax | 1% of whichever is larger — width or height |
svh / svw | 1% of the smallest possible viewport (mobile toolbars expanded) |
lvh / lvw | 1% of the largest possible viewport (mobile toolbars collapsed) |
dvh / dvw | 1% of the current, live viewport (updates as toolbars show/hide) |
Translate a vw/vh value to px at a real screen width with the viewport units calculator — the mobile 100vh bug and the fix are covered in the viewport units guide.
clamp() formula
Fluid value between a minimum size at a small viewport and a maximum size at a large viewport:
slope = (max_px - min_px) / (max_vw_px - min_vw_px) vw term = slope * 100 constant = min_px - (slope * min_vw_px) /* then divide by 16 for rem */ font-size: clamp(MINrem, CONSTANTrem + VWvw, MAXrem);
Worked example — 16px at a 320px viewport growing to 24px at a 1280px viewport:
clamp(1rem, 0.8333rem + 0.8333vw, 1.5rem)
Generate a value for your own min/max/viewport pair with the CSS clamp() generator — full walkthrough in the clamp() guide.