rem Root Consistency Checker

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

Description

A rem length resolves using the root element's font size.

A rem length resolves using the root element's font size. Comparing an expected length with an observed pixel value can expose a wrong assumed root size or an inconsistency in supplied measurements.1

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

When to use rem Root Consistency Checker

Use this tool to resolve a nonnegative rem length against the root font size and compare it with a supplied computed pixel length.

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 rem Root Consistency Checker 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, remValue, observedPixels, tolerance using the field table and calculation rules, then run the tool.
  3. Read expectedPixels, consistent. 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
remValueLength in remnumber; minimum: 0Required
observedPixelsObserved pixel lengthnumber; minimum: 0Required
toleranceAbsolute pixel tolerancenumber; minimum: 0Required

Enter nonnegative root font size, rem length, observed pixel length and absolute pixel tolerance. The tool multiplies the root size by the rem value and compares the absolute difference inclusively with the tolerance. Equality passes; zero size or zero rem gives an expected zero. A nonfinite resolved length is an error.

expectedPixels = rootSize × remValue; consistent = |expectedPixels − observedPixels| ≤ tolerance

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

Output fieldMeaningValue type
expectedPixelsExpected pixel lengthnumber; minimum: 0
consistentWithin toleranceboolean
json
{
  "input": {
    "rootSize": 16,
    "remValue": 2,
    "observedPixels": 32,
    "tolerance": 0
  },
  "output": {
    "expectedPixels": 32,
    "consistent": true
  }
}

Limitations and assumptions

This does not read computed styles, determine the root font size or diagnose browser rounding and zoom. It handles nonnegative lengths only and uses an absolute tolerance, not a relative percentage. The observations must use the same CSS pixel convention.

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. A successfully returned false flag is an evaluated outcome; its meaning is explained above.

Alternative or Complementary methods

Use em Font-Size Compounding Depth Calculator: Calculate a nested font size from a root size and successive nonnegative em font-size multipliers. 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. rem Root Consistency Checker — tool.io

Similar or alternative tools

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