How to Inspect and Control CSS font-size-adjust for Fallback Fonts in Safari Web Inspector

In web design, ensuring typographic legibility during font loading is essential for maintaining strong user experience and meeting Cumulative Layout Shift (CLS) performance metrics. Web fonts downloaded from external content delivery networks often experience loading delays or fail completely due to poor mobile network connectivity. When this occurs, web browsers substitute system fallback fonts defined in the CSS font-family stack.

However, different typefaces possess vastly different proportions. The aspect value of a typeface—the ratio of the x-height of lowercase letters to the overall font size—varies significantly between fonts. If a primary web font with a tall x-height falls back to a system font with a low x-height, body text appears abruptly tiny, lines jump, and reading flow is disrupted. The CSS font-size-adjust property solves this challenge by dynamically scaling the font size based on lowercase letter heights rather than capital heights. Safari on macOS and iOS includes full WebKit support for font-size-adjust, allowing developers to test and fine-tune fallback font metrics using Safari Web Inspector.

Understanding Font Aspect Ratios and font-size-adjust

The aspect value of a font is calculated by dividing its lowercase x-height by its nominal font size (aspect value = x-height / font-size). For example, a font where lowercase letters are 10.8 pixels high at a 20-pixel font size has an aspect value of 0.54.

When you declare font-size-adjust: 0.54;, the browser recalculates the rendered font size of any font loaded in the element using the formula:

c = ( a / a' ) * s

Where s is the declared font size, a is the aspect value specified in the font-size-adjust declaration, a' is the actual aspect value of the currently rendered font, and c is the adjusted size applied by the browser rendering engine. If the fallback font has a smaller natural x-height, WebKit scales up the font size so that the lowercase letters match the optical height of the intended primary font.

Modern CSS syntax also supports metric keywords:

  • font-size-adjust: none;: Disables automatic size adjustments.
  • font-size-adjust: <number>;: Directly specifies the target aspect value.
  • font-size-adjust: ex-height <number>;: Normalises based on the x-height metric.
  • font-size-adjust: cap-height <number>;: Normalises based on capital letter heights.
  • font-size-adjust: from-font;: Automatically extracts the aspect value directly from the primary font file’s OS/2 metric tables.

Enabling Developer Features in Safari

To inspect typography and CSS font adjustments in Safari, enable developer tools:

  1. Launch Safari on your Mac and open Settings (or press Command + ,).
  2. Navigate to the Advanced tab.
  3. Select Show features for web developers.
  4. Close the Settings window.

Right-click the text element on your webpage and select Inspect Element to launch Safari Web Inspector.

Inspecting Active Typeface Metrics in the Fonts Panel

To determine the natural aspect value of your primary font and compare it with system fallbacks:

  1. In Safari Web Inspector, select the text node within the Elements DOM tree.
  2. In the right-hand details pane, click the Fonts tab.
  3. Inspect the Font Details card, which displays the active typeface family, source file, and font format.
  4. Observe the rendered baseline, x-height, and cap-height guidelines displayed in Web Inspector’s visual layout previews.

Testing font-size-adjust Interactively in the Styles Pane

You can simulate how fallback fonts behave and evaluate font-size-adjust declarations live in the Styles panel:

  1. Switch to the Styles tab in Web Inspector.
  2. Locate the font-family declaration for your text container.
  3. Temporarily disable the primary web font by modifying the font stack or unchecking the rule, forcing Safari to render the system fallback font (such as Helvetica Neue or Georgia).
  4. Add a new declaration: font-size-adjust: 0.54;.
  5. Toggle the declaration checkbox on and off to observe how WebKit instantly scales the fallback font so that its lowercase text aligns with your desired design proportions.
/* Example font stack with fallback size compensation */
.article-prose {
    font-family: "CustomSerif", Georgia, "Times New Roman", serif;
    font-size: 1.125rem;
    line-height: 1.6;
    font-size-adjust: 0.52;
}

Testing the Modern from-font Keyword

Rather than manually calculating aspect ratios, test modern WebKit support for from-font:

/* Automatically extract aspect ratio from the primary web font */
.article-prose {
    font-size-adjust: from-font;
}

When declared, WebKit reads the primary font’s internal metadata. If the network connection drops and the browser switches to a fallback font, Safari automatically applies the primary font’s aspect ratio to the fallback, preventing disruptive text shifts and maintaining layout stability.

Verifying Layout Shift Prevention

After implementing font-size-adjust, verify layout stability using Web Inspector’s Timelines tab:

  1. Switch to the Timelines tab and start a recording.
  2. Reload the webpage with simulated network throttling (under the Network tab).
  3. Inspect the Layout Shifts track.

When fallback fonts are properly size-adjusted, layout shift scores approach zero because body paragraph heights remain identical before and after the web font loads.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.