DELIGHTFULDEV

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.

pxremem (at 16px parent)
8px0.5remat 16px parent: 0.5em
10px0.625remat 16px parent: 0.625em
12px0.75remat 16px parent: 0.75em
14px0.875remat 16px parent: 0.875em
16px1remat 16px parent: 1em
18px1.125remat 16px parent: 1.125em
20px1.25remat 16px parent: 1.25em
24px1.5remat 16px parent: 1.5em
28px1.75remat 16px parent: 1.75em
32px2remat 16px parent: 2em
36px2.25remat 16px parent: 2.25em
40px2.5remat 16px parent: 2.5em
48px3remat 16px parent: 3em
56px3.5remat 16px parent: 3.5em
64px4remat 16px parent: 4em
72px4.5remat 16px parent: 4.5em
96px6remat 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 pairDecimalOpacity
ff255100%
e6230~90%
cc204~80%
bf19175%
9915360%
80128~50%
6610240%
4d77~30%
335120%
1a26~10%
0000%

HSL's hue is a position on the color wheel (0–360°) — saturation and lightness then adjust vividness and darkness independently of hue:

HueApproximate color
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:

WidthTypical device classNotes
320pxSmall phoneiPhone SE and similarly narrow devices — the safe floor for a min-width test
375pxStandard phoneiPhone 12–15 class widths; the most common mobile test width
428pxLarge phoneLarger iPhone Pro Max / Android phablet widths
600pxSmall tablet / large phone landscapeA common first "tablet-ish" media query step
768pxTablet portraitiPad portrait; classic Bootstrap "md" breakpoint
1024pxTablet landscape / small laptopiPad landscape; common sidebar-collapse point
1280pxLaptopA frequent "desktop" fluid-scale upper bound
1440pxDesktopCommon full-HD-ish desktop width
1920pxLarge desktopFull 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

RatioDecimalTypical use
1 / 11.0Avatars, square thumbnails, icon tiles
4 / 31.33Older photo/video standard, some product shots
3 / 21.5DSLR photography default
16 / 101.6Some laptop/monitor screens
16 / 91.78Widescreen video embeds (YouTube, Vimeo)
21 / 92.33Ultrawide hero banners, cinematic crops
9 / 160.5625Vertical video (Stories/Reels/Shorts style embeds)
1.618 / 11.618Golden 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

LevelText sizeMinimum ratio
AANormal text4.5:1
AALarge text (≥24px, or ≥18.66px bold)3:1
AAUI components / graphics (1.4.11)3:1
AAANormal text7:1
AAALarge text4.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

UnitMeaning
vw1% of viewport width
vh1% of viewport height
vmin1% of whichever is smaller — width or height
vmax1% of whichever is larger — width or height
svh / svw1% of the smallest possible viewport (mobile toolbars expanded)
lvh / lvw1% of the largest possible viewport (mobile toolbars collapsed)
dvh / dvw1% 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.

← Back to the Dev Journal