CSS Units
62 CSS units covering all specification categories: absolute lengths (px, cm, in, pt, pc, mm, Q), relative lengths (em, rem, vw, vh, and the full set of viewport, container-query, and font-relative units), angles (deg, rad, turn, grad), time (s, ms), frequency (Hz, kHz), resolution (dpi, dpcm, dppx, x), and the grid flex unit fr.
Quick fetch
Stable URL. CORS-enabled. No auth.
curl https://staticdata.dev/v1/css-units.json
Or use as a typed import:
import { cssUnits } from "https://staticdata.dev/v1/css-units.ts"
Formats
- JSON 8.0 KB
/v1/css-units.json
min: 6.6 KB · /v1/css-units.min.json
- CSV 4.2 KB
/v1/css-units.csv
- TypeScript 8.2 KB
/v1/css-units.ts
export const cssUnits
type CssUnit = (typeof cssUnits)[number]
Schema
Each record in the dataset has the following shape.
| Field | Type | Description | Example |
|---|---|---|---|
| unit | string | The CSS unit token (e.g. px, em, deg) | px |
| category | string | Unit category: length-absolute, length-relative, angle, time, frequency, resolution, or flex | length-absolute |
| description | string | Human-readable explanation of the unit and its relationship to other units | Pixels. 1px = 1/96 of 1in. The reference pixel unit for CSS. |
Preview
First 10 records.
| unit | category | description |
|---|---|---|
| cm | length-absolute | Centimeters. 1cm = 96px/2.54 ≈ 37.8px. |
| mm | length-absolute | Millimeters. 1mm = 1/10 of 1cm. |
| Q | length-absolute | Quarter-millimeters. 1Q = 1/4 of 1mm. Primarily used in Japanese print layouts. |
| in | length-absolute | Inches. 1in = 2.54cm = 96px. |
| pc | length-absolute | Picas. 1pc = 12pt = 1/6 of 1in. |
| pt | length-absolute | Points. 1pt = 1/72 of 1in ≈ 1.333px. |
| px | length-absolute | Pixels. 1px = 1/96 of 1in. The reference pixel unit for CSS. |
| cap | length-relative | Cap height of the element's font — the height of a capital letter. |
| ch | length-relative | Width of the '0' (zero) glyph in the element's font. |
| em | length-relative | Relative to the font-size of the element itself. 1em = current font-size. |
Fetch examples
Drop-in snippets in five languages.
curl -sSL https://staticdata.dev/v1/css-units.json | jq '.[0]' import type { CssUnit } from "https://staticdata.dev/v1/css-units.ts";
const res = await fetch("https://staticdata.dev/v1/css-units.min.json");
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
const cssUnits: CssUnit[] = await res.json();
console.log(cssUnits[0]); import urllib.request, json
with urllib.request.urlopen("https://staticdata.dev/v1/css-units.min.json") as r:
cssUnits = json.load(r)
print(cssUnits[0]) package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("https://staticdata.dev/v1/css-units.min.json")
if err != nil { panic(err) }
defer resp.Body.Close()
var data []map[string]any
if err := json.NewDecoder(resp.Body).Decode(&data); err != nil {
panic(err)
}
fmt.Println(data[0])
} use serde_json::Value;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let body = ureq::get("https://staticdata.dev/v1/css-units.min.json").call()?.into_string()?;
let data: Vec<Value> = serde_json::from_str(&body)?;
println!("{:?}", data.first());
Ok(())
} Sources and methodology
This dataset was curated from the CSS Values and Units Module Level 4 W3C specification and corroborated against MDN Web Docs. It includes the 62 unit tokens defined in CSS Values and Units Level 4, CSS Containment Level 3 (container-query units) and CSS Grid (fr), as of October 2026, across seven categories, from the classic px and em through modern viewport units (svh, dvw, lvmin) and container-query units (cqw, cqi, cqb).
The category field uses one of seven values: length-absolute for physical/fixed-size units (px, cm, in, mm, pt, pc, Q); length-relative for units derived from font metrics, viewport dimensions, or container size; angle for rotation and hue values; time for animation and transition durations; frequency for the aural CSS speech units; resolution for media query resolution detection; and flex for the CSS Grid fractional unit fr. Records are grouped by category (not sorted alphabetically).
Frequency units (Hz, kHz) are part of the CSS spec but currently only apply to the largely unimplemented aural/speech stylesheet feature. The Q (quarter-millimeter) unit has limited browser tooling adoption but is part of the CSS spec and is used in Japanese print workflows. Most other units have broad browser support; some newer ones (such as the root-font units rcap, rex, ric and rch) arrived later, so check current browser support data before relying on them.
Versioning
URLs under /v1/ are stable: field names and types will not change in a way
that breaks consumers. Values can be corrected or records added when the upstream source
changes; schema-incompatible updates ship under a new version path. See the
css-units changelog for this dataset's history.
Related datasets
More Code datasets
- ansi-colors
- ascii
- cron-presets
- css-at-rules
- css-functions
- css-pseudo-classes
- css-pseudo-elements
- data-units
- exit-codes
- file-signatures
- hash-algorithms
- js-array-methods
- js-math-methods
- js-object-methods
- js-string-methods
- json-schema-keywords
- jwt-claims
- mathematical-constants
- measurement-units
- node-builtin-modules
- owasp-top-10
- periodic-table
- physical-constants
- posix-signals
- programming-languages
- regex-flags
- regex-patterns
- roman-numerals
- si-base-units
- si-derived-units
- si-prefixes
- spdx-licenses
- strftime-tokens
- tailwind-colors
- time-units
- unicode-blocks
- unicode-general-categories
- unicode-planes
- unix-file-permissions
- xterm-256-colors