CSS Font-Size Units Explained

Pixels represent absolute, fixed measurements tied to your screen resolution. A 16px font will render identically on every device, but won't respond to user preferences or parent-element sizing. This rigidity makes px useful for precise, non-scaling elements but problematic for accessible, flexible layouts.

Ems are relative units that inherit from their parent's font size. If you set an element to 1.5em and the parent is 16px, the result is 24px. This cascading behavior makes ems powerful for modular components, though nested elements can compound unexpectedly. One em always equals 100% of the inherited size.

Points (pt) are print-industry units where 1 pt equals exactly 0.75 pixels. Web browsers treat 12pt as roughly 16px because traditional print assumes 72 points per inch. Points are rarely used in modern web design but appear in exported PDFs or legacy stylesheets.

Percentages scale relative to the parent element, defaulting to 100% of inherited size. A 150% font size on a 16px parent produces 24px. Percentages and ems behave similarly, making either suitable for responsive designs.

Unit Conversion Formulas

These relationships form the foundation of all CSS unit conversions. The calculations chain together, so converting from one unit type to another requires applying the appropriate formula in sequence.

em = px ÷ base

px = pt ÷ 0.75

px = (percent × base) ÷ 100

pt = em × base × 0.75

percent = (pt ÷ 0.75) × 100 ÷ base

  • px — Font size in pixels
  • em — Font size in ems (relative to base)
  • pt — Font size in points
  • percent — Font size as percentage of base
  • base — Base font size, typically 16px for web

Practical Conversion Walkthrough

Suppose you have a design specification in 24pt and need to express it as em values with a base of 16px. First, convert points to pixels: 24pt ÷ 0.75 = 32px. Then divide by the base: 32px ÷ 16px = 2em. Since 1em equals 100%, 2em equals 200%.

Conversely, if you want 1.25em in points using a 16px base, multiply backward: 1.25em × 16px × 0.75 = 15pt. These relationships remain constant regardless of your chosen base size, though changing the base proportionally scales all computed values.

Modern responsive designs typically set base size in pixels (often 16px or 18px) then use em or percentage declarations for scaling components. This hybrid approach preserves absolute control over root typography while allowing sub-elements to adapt flexibly.

Critical Conversion Pitfalls

Avoid these common mistakes when working with CSS units.

  1. Nested Em Multiplication — Em values compound when nested inside em-sized parents. A 1.2em element inside a 1.2em parent becomes 1.44em relative to the document root, not 1.2em. Always calculate em values relative to their direct parent, not the base.
  2. Base Size Assumptions — If you don't explicitly set a base size in the calculator, it defaults to 16px—the browser standard. However, users may override this or your site might declare a different base. Always verify your assumption before converting, especially when collaborating with designers using different defaults.
  3. Point Units in Digital Contexts — Points were invented for print, where DPI is fixed. Browsers render points inconsistently across operating systems and browsers. Avoid using pt for web typography unless exporting to PDF; use px or em instead.
  4. Percentage Inheritance Chains — Like ems, percentages inherit from parent elements. If a parent is 80% and a child is 50%, the child is actually 40% of the document root. Track the inheritance chain carefully in complex layouts.

When to Use Each Unit

Use pixels (px) for fixed-width elements, borders, and properties that should never scale. Px units work well for consistent spacing or decorative elements unrelated to typography.

Use ems (em) for scalable typography, padding, and margins within components. Ems ensure that spacing scales proportionally with text size, keeping your design systems flexible.

Use percentages (%) for responsive layouts and font sizing when you want inheritance without nesting complexity. Percentages are cleaner in many scenarios because they reset to the base in each new context.

Avoid points (pt) in web layouts. Reserve pt for print stylesheets or PDF generation, where print-industry conventions apply.

Frequently Asked Questions

What is the default base size for em conversions?

The standard web default is 16 pixels. Most browsers and design systems assume 16px as the root font size unless overridden in CSS. Some modern designs use 18px for improved readability, but always verify your project's base size. If you've set a custom base in your HTML or CSS (for example, 14px), adjust the calculator's base setting accordingly to get accurate conversions.

Why do nested em values compound instead of staying constant?

Em is a relative unit defined as "the current font size of the element." When you nest elements, each child's em is relative to its parent's computed size, not the root. A 1.2em child inside a 1.2em parent inherits a parent size of 1.2 × 16px = 19.2px, making the child 1.2 × 19.2px = 23.04px. This cascading behavior is intentional, enabling modular scaling, but requires careful planning in deeply nested layouts.

Is it better to use em or percentage for responsive font sizing?

Both work well, but serve slightly different needs. Percentages are simpler conceptually because each element inherits exactly from its parent with no compounding. Ems offer finer typographic control and are often preferred in type-scale systems. For most responsive designs, percentage-based font sizing is less error-prone, while ems shine in component libraries where spacing scales alongside type. Choose based on your layout complexity and team preference.

How do I convert a point size from print to web pixels?

Divide the point value by 0.75. For example, 12pt ÷ 0.75 = 16px. This conversion works because browsers assume 72 points per inch (standard print DPI), making 1pt equal to 1/72 inch. However, web em sizes are arbitrary and depend on your chosen base, so this formula alone won't give you the final em value—convert pt to px first, then px to em by dividing by your base size.

Can I use mixed units in my CSS stylesheet?

Yes, and most real projects do. You might use px for borders, em for component spacing, percentage for responsive font sizes, and pt in print stylesheets. Mixing units is safe as long as you understand each unit's scope. The challenge arises with nested em calculations; in those contexts, maintaining consistent units within a component prevents mistakes.

Why don't designers use pixels for all web typography anymore?

Pixels prevent text from scaling when users change their browser's default font size or zoom level. Users with vision impairments often increase their base font size, and pixel-based text ignores this setting. Em and percentage units respect user preferences, improving accessibility. Additionally, responsive design requires relative units to adapt layouts across devices—fixed pixel sizes don't scale elegantly.

More conversion calculators (see all)