CSS relative length conversion
Convert CSS relative lengths using explicitly specified contextual references in px
Enter the reference values required by the units in use. Browser defaults are not inferred.
The percentage reference dimension varies by property and is not determined automatically.
Results
—
- Equivalent CSS px value
- —px
Results update automatically when the required values are entered.
Method, applicability and sources
Calculation method
1 rem = resolved root font-size; 1 em = reference font-size; 1 vw = viewport width ÷ 100; 1 vh = viewport height ÷ 100; 1% = property's reference dimension ÷ 100. Converted value = input length × source-unit px factor ÷ target-unit px factor.
Worked example (hypothetical values)
Example: with a 16 px root font size, 2 rem = 32 px. With a viewport width of 1,000 px, 5 vw = 50 px.
Applicability and limitations
Web authors calculating CSS relative lengths under known layout conditions. Excludes unresolved computed styles, auto, calc(), container units, dynamic viewports, automatic percentage-reference inference, rem on the root's own font-size, and browser rendering or zoom differences.
Method and sources
Method: CSS Values and Units 4 WD 2024-03-12; CSS Box Model 3 REC 2024-04-11 / conversion implementation v1. Data recorded: 2026-11-20.