How to Inspect and Control CSS text-decoration-thickness in Safari Web Inspector

In modern web typography, precision over decorative stroke rendering is critical for maintaining visual harmony and legibility across high-density displays. Historically, CSS text decorations—such as underlines, overlines, and line-throughs—rendered with browser-dependent thicknesses derived strictly from font glyph metrics, often producing thin, fragile lines or heavy, distracting bars across custom web fonts. The CSS Text Decoration Module Level 4 standardises text-decoration-thickness, empowering developers to explicitly define the stroke weight of text decoration lines. In Safari, WebKit implements full support for absolute lengths, percentage values, and font-relative units. Using Safari Web Inspector, web authors and front-end developers can inspect computed stroke weights, debug cascade conflicts, and test responsive typographic hierarchies in real time.

Understanding CSS text-decoration-thickness and WebKit Rendering

The text-decoration-thickness CSS property governs the stroke width of text decoration lines specified by text-decoration-line (such as underline, line-through, or overline). WebKit supports several distinct value types:

  • auto (Initial Value): The browser selects an appropriate stroke thickness based on the font family and font size metrics embedded within the active typeface.
  • from-font: If the loaded font file contains an explicit underline thickness specification in its internal OpenType or TrueType tables (such as the post or OS/2 table), WebKit uses that exact metric. If the font lacks embedded metrics, it falls back to auto behaviour.
  • Absolute and Relative Lengths: Precise values such as 2px, 0.15em, 0.2rem, or 0.12ch allow authors to scale underline thickness proportionally to surrounding text dimensions or viewport units.
  • Percentage Values (<percentage>): Defines the stroke thickness as a percentage of 1em in the element’s current font size. For example, text-decoration-thickness: 10% on a 20px font produces a 2px stroke.

When combined with companion properties such as text-decoration-color, text-underline-offset, and text-decoration-skip-ink, WebKit renders typographic underlines that maintain crisp aesthetic consistency without clipping lowercase descenders (such as letters “g”, “j”, “p”, “q”, and “y”).

Enabling Safari Web Inspector and Selecting Text Elements

To inspect and manipulate text decoration properties in Safari on macOS:

  1. Ensure developer features are enabled by navigating to Safari > Settings > Advanced (or Preferences) and ticking Show features for web developers.
  2. Right-click the decorated text element on the webpage (such as a navigation hyperlink, headline, or call-to-action anchor) and choose Inspect Element.
  3. The Safari Web Inspector opens automatically, focusing the selected node within the Elements DOM tree hierarchy.

Inspecting Computed Decoration Thickness in the Styles Pane

Within the Web Inspector, locate the right-hand sidebar and switch between the Styles tab and the Computed tab:

  • In the Styles Tab: Review all CSS rules targeting the selected element. Look for explicit declarations of text-decoration-thickness or composite shorthand rules (text-decoration: underline red 2px). If a rule is crossed out with a strikethrough, another selector with higher specificity or an !important flag is overriding the declaration.
  • In the Computed Tab: Scroll down to the Typography or Text section (or use the filter search bar to query thickness). The Computed panel reveals the resolved pixel value that WebKit passes to Core Graphics for rasterisation, regardless of whether it was defined via percentages, em units, or from-font metrics.

Live-Testing Dynamic Thickness Values in the Terminal Console and CSS Editor

Safari Web Inspector allows real-time interactive adjustments directly within the rule declaration block. Double-click the style block in the Styles tab and add or modify the property:

/* Example: Defining proportional and absolute underline thicknesses */
.custom-link {
    text-decoration-line: underline;
    text-decoration-color: #0070c9;
    text-decoration-thickness: 0.12em;
    text-underline-offset: 0.25em;
    text-decoration-skip-ink: auto;
}

/* Example: Emphasising active navigation anchors */
.nav-active {
    text-decoration-line: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
}

Use the Up and Down arrow keys while focusing numerical values in the Styles editor to increment or decrement stroke weights by 1px or 0.1em increments (hold Shift for 10px steps), observing the immediate visual effect on the rendered page.

Testing text-decoration-thickness via JavaScript Console

To programmatically evaluate the computed thickness across multiple viewport breakpoints or dynamic themes, execute queries within the Safari Web Inspector Console:

// Select the target link element
const targetElement = document.querySelector('.custom-link');

// Retrieve the computed style declaration
const computedStyles = window.getComputedStyle(targetElement);

// Output the resolved text-decoration-thickness
console.log('Computed Thickness:', computedStyles.textDecorationThickness);

// Dynamically adjust thickness for testing
targetElement.style.textDecorationThickness = '20%';

Debugging Common WebKit Rendering Quirks and Caveats

When implementing text-decoration-thickness across modern web layouts, keep the following WebKit behaviours in mind:

  • Subpixel Anti-Aliasing on Standard Displays: On non-Retina displays, fractional pixel thicknesses (such as 0.5px) may snap to 1px to avoid blurry anti-aliasing artifacts. On high-DPI Retina displays, WebKit accurately maps fractional thicknesses to physical device pixel grids.
  • Shorthand Property Resetting: Using the CSS shorthand text-decoration: underline without specifying thickness resets text-decoration-thickness back to auto. Always declare the shorthand first before applying individual longhand overrides, or include the thickness directly inside the modern shorthand syntax (text-decoration: underline 2px solid currentColor).
  • Inheritance Rules: In CSS, text decorations are drawn across descendant inline elements rather than inherited in the traditional DOM cascade sense. If an underline thickness appears unresponsive on a child <span>, inspect the parent <a> or container element that originally established the decoration line.

Get the best tech tips delivered straight to your inbox.

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