EX to PX Converter

Convert CSS x-height (ex) units into precise computed pixel values across popular web typefaces

EX to PX Converter

Font Sizepx
Font Family

Result: px

ex @ 16px serif = px

X-height ratio: 0.46

Font Size: 16px
x-height
Lowercase 'x' height: 7.4px
Common EX Presets:

What are EX Units in CSS?

EX units in CSS are relative units based on the x-height of the current font. 1ex equals the height of the lowercase letter 'x' in the specified font family and size.

// EX units in CSS
.typography {
  font-size: 16px;
  line-height: 2ex;
  margin-bottom: 1.5ex;
}

Why Use EX Units?

  • Font-Aware Sizing: Automatically adapts to different fonts
  • Typography Consistency: Maintains proportions relative to text
  • Readability: Perfect for line-height, margins, and spacing
  • Cross-Font Compatibility: Works consistently across different font families
  • Historical Typography: Based on traditional typographic measurements

Conversion Formula:

// EX to PX conversion formula
PX = EX × Font Size × X-Height Ratio

// Example: 2ex at 16px Arial (x-height ratio: 0.52)
16.64px = 2 × 16 × 0.52

// Where X-Height Ratio = Height of 'x' ÷ Font Size

X-Height Ratios for Common Fonts:

Font FamilyX-Height Ratio1ex at 16pxTypical UseFont Characteristics
Verdana0.558.8pxWeb typography, UILarge x-height, high readability
Arial0.528.32pxGeneral purpose, webMedium x-height, sans-serif
Georgia0.487.68pxReading, articlesWeb-safe serif, good x-height
Times New Roman0.467.36pxPrint, formal documentsSmall x-height, traditional
Courier New0.589.28pxCode, monospaceMonospace, large x-height
Helvetica0.528.32pxPrint design, brandingClassic sans-serif
Comic Sans MS0.548.64pxInformal, casualLarge x-height, rounded
Garamond0.447.04pxBooks, literatureSmall x-height, elegant

Visual Representation:

// Anatomy of typography measurements
Font Size: Total height from top of ascenders to bottom of descenders
X-Height: Height of lowercase 'x' (no ascenders/descenders)
Cap Height: Height of uppercase letters
Ascender Height: Height above x-height (b, d, h, etc.)
Descender Depth: Depth below baseline (g, j, p, q, y)
1ex = X-Height of current font

CSS Examples & Usage:

// Typographic spacing with EX units
.article-text {
  font-size: 18px;
  font-family: Georgia, serif;
  line-height: 1.6ex;
  margin-bottom: 2ex;
}

// Button padding relative to text
.btn {
  font-size: 16px;
  font-family: Arial, sans-serif;
  padding: 1ex 2ex;
}

// Form input sizing
input[type=&qout;text&qout;] {
  font-size: 14px;
  height: 3ex;
  padding: 0.5ex;
}

EX vs EM vs REM:

UnitBased OnUse CaseAdvantagesDisadvantages
EXX-height of current fontTypography spacing, vertical rhythmFont-aware, consistent proportionsVaries by font, less commonly used
EMCurrent font sizeRelative sizing, responsive typographySimple, widely supportedCompounds in nested elements
REMRoot font sizeGlobal scaling, consistent sizingConsistent, no compoundingLess flexible for component scaling
PXAbsolute pixelsFixed sizes, precise controlPrecise, predictableNot responsive, accessibility issues

Best Practices:

  • Use EX units for line-height to maintain typographic rhythm
  • Combine with EM units for comprehensive typographic scale
  • Test with different fonts as x-height varies significantly
  • Use for vertical spacing (margins, padding) in text-heavy layouts
  • Consider accessibility - EX units scale with text size changes
  • For body text, 1.4-1.6ex line-height is optimal for readability

Historical Context:

// EX units in typographic history
Origin: Traditional typography measurement
Relation to EM: In metal type, 1em = width of 'M', 1ex ≈ 0.5em
Digital Adaptation: CSS adopted EX as x-height measurement
Modern Use: Less common than EM/REM but valuable for typography
Browser Support: Excellent (all modern browsers)

Common EX Values:

// Typical EX unit applications
Line height: 1.5-1.8ex (optimal readability)
Paragraph spacing: 1.5-2ex (visual separation)
Button padding: 0.5-1ex (vertical), 1-2ex (horizontal)
Form inputs: 2-3ex height
Heading margins: 0.5-1ex top, 1-1.5ex bottom
Block quotes: 1ex left padding
List items: 0.5ex between items

Understanding the CSS EX Unit and Typographic X-Height

In classical book typography and digital interface design, the vertical dimension of text is characterized by intricate proportional relationships. While units like px represent static raster measurements and em represents the total typographic bounding box, the CSS EX unit (ex) is uniquely bound to the physical vertical stature of lowercase letterforms.

According to the W3C CSS Values and Units Module, exactly 1ex corresponds to the x-height of the element's current font. The term x-height originates from traditional metal typesetting, defining the distance between the baseline (the invisible line upon which letters sit) and the mean line (the top of flat lowercase letters such as 'x', 'v', 'w', and 'z'). It explicitly excludes uppercase ascenders (like the top of 'd' or 'k') and descending tails (like the bottom of 'p' or 'y'). Consequently, the ex unit provides web developers with a precise tool for sizing UI elements that align with lowercase text bodies.

The Mathematical Conversion Formula: From EX to Pixels

To convert an ex value into absolute pixels, you multiply the target EX quantity by the computed font-size of the element and by the specific typeface's x-height ratio:

PX = EX × Font Size in Pixels × X-Height Ratio

Because different type designs allocate varying percentages of their em-square to the lowercase letters, the x-height ratio varies significantly across popular system and web fonts:

  • Verdana: Built specifically for on-screen legibility at small sizes, Verdana has an exceptionally generous x-height ratio of approximately 0.55.
  • Arial & Helvetica: Standard modern grotesk sans-serif fonts feature balanced x-height ratios of approximately 0.52.
  • Georgia: A screen-optimized transitional serif with a healthy x-height ratio of 0.48.
  • Times New Roman: A compact newspaper serif designed to fit maximum words into narrow columns, featuring an x-height ratio of approximately 0.46.
  • Garamond: A classical Renaissance serif with an elegant, compact lowercase body, averaging roughly 0.44.

For example, if you declare an inline notification badge with a vertical height of 1.5ex inside a paragraph rendered in Arial at 16px, the computed pixel height is calculated as:
1.5 × 16px × 0.52 = 12.48px.

Comprehensive EX to PX Reference Matrix Across Typefaces

The table below presents the computed pixel heights for various EX values evaluated across standard font families at a standard 16px base font size:

EX ValueGaramond (0.44)Times New Roman (0.46)Georgia (0.48)Arial (0.52)Verdana (0.55)
0.5 ex3.52 px3.68 px3.84 px4.16 px4.40 px
1.0 ex7.04 px7.36 px7.68 px8.32 px8.80 px
1.5 ex10.56 px11.04 px11.52 px12.48 px13.20 px
2.0 ex14.08 px14.72 px15.36 px16.64 px17.60 px
2.5 ex17.60 px18.40 px19.20 px20.80 px22.00 px
3.0 ex21.12 px22.08 px23.04 px24.96 px26.40 px

High-Impact Real-World Use Cases for the EX Unit

While many web developers default to rem or px for all sizing needs, using ex offers distinct advantages in specific UI design challenges:

1. Inline Status Icons and Badges

When placing small verification checks, status indicators, or chevron arrows immediately alongside running text, sizing them with height: 1ex; width: 1ex; aligns them perfectly with the visual midline of lowercase letters, preventing the awkward top-heavy floating look caused by sizing with 1em.

2. Subscripts, Superscripts, and Math Formulas

In scientific, academic, and financial applications, vertical offsets for mathematical notation (like footnotes or chemical formulas) styled with vertical-align: 0.5ex; lift characters in harmonious proportion to the actual lowercase text height.

3. Harmonious Paragraph Spacing

Setting vertical paragraph margins using margin-bottom: 2ex; creates a typographic vertical rhythm that scales directly with the optical density of the selected font rather than its arbitrary bounding box.

4. Optical Underlines and Strikethroughs

Custom decorative borders and strike-through elements styled with top: 0.5ex; sit naturally across the visual middle of lowercase text without awkward misalignment.

Comparing CSS Font Units: EX vs EM vs CH vs REM

Choosing the right relative font unit is essential for maintainable, accessible design systems. Here is how ex compares with other typographic measurements:

UnitMeasurement MetricOrientation AxisBest Production Application
EXHeight of lowercase 'x'VerticalInline icons, badges, subscripts, optical vertical alignment
EMFull bounding em-square of current elementBothComponent-scoped padding, buttons, icon containers
CHAdvance width of numeral '0'HorizontalOptimal text column measure (65ch), input field widths
REMRoot element (<html>) font sizeBothGlobal typography scale, grid spacing, section margins

Browser Rendering Nuances and Font Fallback Considerations

When implementing ex in production web applications, frontend engineers should keep two technical considerations in mind:

  • Synthetic X-Height Fallback: If an open-source or custom web font file is poorly authored and omits the standard OpenType OS/2 metrics table containing the x-height value, modern web browsers gracefully fallback to computing 1ex = 0.5em.
  • Web Font Loading Transitions: When replacing a system fallback font (such as Arial) with a custom branded serif (such as Garamond), the computed pixel value of 1ex will decrease slightly due to Garamond’s more compact x-height. Using CSS font-size-adjust: from-font; or matching x-height ratios in your font loading strategy prevents optical jump.

Under the Hood: How Browsers Extract X-Height from Font Files

Modern web layout engines (such as Blink in Chrome/Edge, Gecko in Firefox, and WebKit in Safari) do not guess or approximate the height of lowercase characters when parsing stylesheets. Inside every properly compiled TrueType (.ttf) and OpenType (.otf or .woff2) digital font file sits an essential binary metadata structure known as the OS/2 table.

Within this table, font foundries populate the sxHeight field, an integer specifying the design units dedicated to the height of the lowercase 'x' relative to the font’s units-per-em (usually 1000 or 2048 units). When the browser’s text shaper loads the font, it computes 1ex by evaluating:
Computed 1ex = (sxHeight ÷ unitsPerEm) × Computed Font Size.

If the sxHeight entry is missing, modern rendering engines measure the actual bounding box of the lowercase 'x' glyph directly. Only when the 'x' glyph is entirely absent from the font character map does the layout engine employ the synthetic fallback of 0.5em.

Step-by-Step Production Code Recipe: Optically Centered Badges

A frequent annoyance in design system engineering is styling inline verification icons or badge tags (such as a "Verified Author" pill or status indicator) beside heading or paragraph text. Sizing the badge with fixed pixels causes misalignment whenever font sizes adapt, while sizing with em makes the badge look bulky because it matches the entire ascender-to-descender box.

By applying the ex unit, you anchor the badge directly to the optical heart of the text:

.verified-badge {
  display: inline-flex;
  align-items: center;
  /* Sized to match the visual lowercase height */
  height: 1.4ex;
  padding-inline: 0.8ex;
  font-size: 0.85ex;
  border-radius: 9999px;
  vertical-align: middle;
  background-color: #e0f2fe;
  color: #0284c7;
}

This rule ensures that whether the heading text scales to 32px on desktop or 20px on mobile, the verification pill automatically scales in lockstep with the lowercase text line, maintaining immaculate optical equilibrium without requiring complex CSS margins or hardcoded pixel hacks.

Conclusion and Summary

CSS EX units empower frontend engineers to achieve pixel-perfect optical alignment by anchoring vertical dimensions directly to the lowercase x-height of web typography. By using the interactive calculator above to preview pixel conversions across typefaces and pairing ex with modern responsive CSS properties, you can elevate the craftsmanship and visual balance of your web interfaces.

Frequently Asked Questions (FAQs)

An EX to PX Converter is a typography utility that calculates the exact pixel (px) height of CSS 'ex' units based on the active font family's x-height ratio and computed font size.

The EX unit represents the x-height of the element's current font—specifically, the vertical height of the lowercase letter 'x' (glyph U+0078). It reflects the visible lowercase body of the typeface.

The formula is: PX = EX × Font Size in Pixels × X-Height Ratio. For example, in Arial at 16px font size with an x-height ratio of 0.52, 1ex = 1 × 16 × 0.52 = 8.32px.

Font size measures the entire bounding em-square (which includes room for tall ascenders like 'h' and deep descenders like 'p'). Different typefaces allocate differing portions of that box to lowercase characters—for instance, Verdana has a large x-height (0.55) while Garamond has a compact x-height (0.44).

EX units are ideal for vertical centering of inline icons, badges, subscripts, superscripts, and baseline text accents because they align with the visual midline of lowercase letters rather than the full em-box.

Under the W3C CSS specification, if a web browser cannot determine the x-height from the font metrics table, it defaults to exactly 0.5em (50% of the computed font-size).

EX measures vertical height (the height of the lowercase 'x'), whereas CH measures horizontal width (the width of the numeral '0'). Both are font-relative metrics, but they govern perpendicular layout dimensions.

Yes. Because EX is relative to the element's computed font-size, any changes to font-size via media queries, container queries, or user accessibility settings will automatically scale elements sized in EX.

Explore Related CSS Typography & Length Converters

Seamlessly convert between all CSS typographic and layout units:

Explore Related Tools

Hand-picked utilities and calculators related to this tool.

Pixels Converter