User Rating 0.0
Total Usage 0 times
Category CSS Tools
px
px
em
Is this tool helpful?

Your feedback helps us improve.

About

Mismatched CSS units break responsive layouts. A heading set to 24px on a desktop becomes illegible or oversized when a user adjusts their browser's default font size - because pixels ignore that preference. The em unit scales relative to a base font size (base), typically the parent element's computed font-size. This converter computes the bidirectional relationship: given a base of 16px, a value of 24px equals 1.5em. Get it wrong and your entire typographic scale collapses across breakpoints.

The tool assumes a single inheritance context. Nested em values compound - 1.5em inside a 1.5em parent renders at 2.25em of the root. For deep nesting, consider using rem instead, which always references the root font-size. This tool does not account for compounding. It converts a single level against the base you provide.

pixel to em px to em converter em to px css unit converter font size converter responsive typography css units

Formulas

The conversion between px and em is a linear ratio governed by the base font size of the parent element.

em = pxbase
px = em × base

Where px is the pixel value to convert, em is the resulting relative unit, and base is the parent element's computed font-size in pixels. Most browsers default base to 16px. Note that em compounds through nesting: an element at 1.5em inside another at 1.5em renders at 1.5 × 1.5 = 2.25em of the root. The rem unit avoids this by always referencing the root <html> font size.

Reference Data

Pixels (px)Em at 10px baseEm at 12px baseEm at 14px baseEm at 16px baseEm at 18px baseEm at 20px baseEm at 24px base
80.80.66670.57140.50.44440.40.3333
90.90.750.64290.56250.50.450.375
1010.83330.71430.6250.55560.50.4167
111.10.91670.78570.68750.61110.550.4583
121.210.85710.750.66670.60.5
131.31.08330.92860.81250.72220.650.5417
141.41.166710.8750.77780.70.5833
161.61.33331.142910.88890.80.6667
181.81.51.28571.12510.90.75
2021.66671.42861.251.111110.8333
222.21.83331.57141.3751.22221.10.9167
242.421.71431.51.33331.21
282.82.333321.751.55561.41.1667
323.22.66672.285721.77781.61.3333
363.632.57142.2521.81.5
4043.33332.85712.52.222221.6667
484.843.428632.66672.42
565.64.666743.53.11112.82.3333
646.45.33334.571443.55563.22.6667
727.265.14294.543.63

Frequently Asked Questions

Each em value multiplies against its parent's computed font-size, not the root. If a parent is set to 1.5em (24px at 16px base) and a child is also 1.5em, the child renders at 1.5 × 24px = 36px, which is 2.25em of the root. This compounding makes deeply nested em values unpredictable. Use rem for consistent sizing across nesting depths.
Use em when you want a component's sizing to scale proportionally with its parent's font-size - common for padding, margins, and media-object patterns inside typographic components. Use rem for global consistency (body text, headings, layout spacing). Use px only for borders, shadows, and elements that must not scale (e.g., 1px hairline dividers).
All major browsers (Chrome, Firefox, Safari, Edge) default to 16px for the root html element. However, users can override this in browser settings for accessibility. Designs built with em or rem respect this preference; designs in px ignore it. The 62.5% trick (setting html { font-size: 62.5% }) changes the base to 10px, making mental math easier: 1.6rem = 16px.
No. This tool performs a static arithmetic conversion between px and em at a fixed base. CSS functions like calc(1em + 10px) or clamp() involve runtime resolution by the browser's layout engine and cannot be pre-computed statically. For fluid typography using viewport units (vw), dedicated clamp calculators are more appropriate.
In browser DevTools (F12), select the target element, open the Computed tab, and search for font-size. The value shown in pixels is your base for em calculations on that element's children. Alternatively, run getComputedStyle(element).fontSize in the console. This returns a string like "16px" which you parse to a number.
Precision matters for sub-pixel rendering. Modern browsers render at sub-pixel accuracy. A value of 0.8571em (12px at 14px base) truncated to 0.86em introduces a 0.04px rounding error per element. Over 50 elements on a page, that compounds to ~2px of layout drift. Four decimal places keep error below 0.01px. This converter allows you to configure precision from 1 to 6 decimal places.