em Font-Size Compounding Depth Calculator

Calculate a nested font size from a root size and successive nonnegative em font-size multipliers.

Description

An em font-size multiplier is relative to the inherited font size, so successive nested multipliers compound.

An em font-size multiplier is relative to the inherited font size, so successive nested multipliers compound. A rem measurement instead refers back to the root size and does not compound in this way.1

Calculate a nested font size from a root size and successive nonnegative em font-size multipliers.

When to use em Font-Size Compounding Depth Calculator

Use this tool to calculate a nested font size from a root size and successive nonnegative em font-size multipliers.

Choose the CSS values, dimensions or counts for this calculation. Supply resolved numeric measurements in matching units and the explicit reference box or writing mode where required.

How to use em Font-Size Compounding Depth Calculator and understand its results

  1. Choose the CSS values, dimensions or counts for this calculation. Supply resolved numeric measurements in matching units and the explicit reference box or writing mode where required.
  2. Enter rootSize, multipliers using the field table and calculation rules, then run the tool.
  3. Read fontSize, depth. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
Input fieldMeaningValue type; see rules belowRequirement
rootSizeRoot font sizenumber; minimum: 0Required
multipliersNested em multiplierslist of number; minimum: 0; minimum entries: 0; maximum entries: 1000Required

Enter a nonnegative root font size and the nonnegative multiplier at each nested level in order. Zero root size or any zero multiplier gives zero immediately; an empty list keeps the root size. The tool multiplies the factors and also accumulates their logarithms, using the latter if intermediate multiplication loses numeric range. A nonfinite final size is rejected; underflow can return zero.

fontSize = rootSize × product(multipliers); depth = number of multipliers

Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.

Output fieldMeaningValue type
fontSizeFinal font sizenumber; minimum: 0
depthNesting depthinteger; minimum: 0; maximum: 9007199254740991
json
{
  "input": {
    "rootSize": 16,
    "multipliers": [
      1.5,
      1.5
    ]
  },
  "output": {
    "fontSize": 36,
    "depth": 2
  }
}

Limitations and assumptions

This models nested font-size multipliers only, without the cascade, inheritance lookup, browser minimum font sizes or em lengths on unrelated properties. The root size establishes the output unit. At most 1,000 nested multipliers are accepted.

Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.

Alternative or Complementary methods

Use rem Root Consistency Checker: Resolve a nonnegative rem length against the root font size and compare it with a supplied computed pixel length. For a complementary task, use Translate % Relative To Own Box Width: Resolve a signed horizontal translate percentage against an explicitly supplied reference-box width in pixels; the caller chooses the transform reference box.

References

  1. em Font-Size Compounding Depth Calculator — tool.io

Similar or alternative tools

  • rem Root Consistency Checker

    Resolve a nonnegative rem length against the root font size and compare it with a supplied computed pixel length.

  • Translate % Relative To Own Box Width

    Resolve a signed horizontal translate percentage against an explicitly supplied reference-box width in pixels; the caller chooses the transform reference box.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies