Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 3 min read How-to mediumAdept

Polishing your typography with line height units

The CSS `lh` and `rlh` units, supported in all major browsers since 2023, equal the current element's line height and the root line height respectively. Setting paragraph margins to `1lh` instead of the traditional `1em` keeps paragraph spacing aligned to the text's line grid, producing a more consistent vertical rhythm. The units also work for padding, gaps and other dimensions. With about 94% browser support, a fallback declaration in `em` before the `lh` one gives a progressive-enhancement path.

Related posts

  • Better typography with text-wrap pretty

    WebKit mediumAdept

    WebKit's implementation of `text-wrap: pretty` in Safari Technology Preview 216 evaluates the whole paragraph rather than one line at a time. It avoids short last lines, improves rag by targeting a wrap range short of the box edge, and reduces hyphenation; it does not yet address rivers. Chromium's version only adjusts the last four lines, and the CSS spec deliberately leaves the improvements up to each browser. Performance depends on paragraph length, not on how many elements use it, so typical paragraphs are safe. `balance` equalizes line lengths and can leave text narrower than its container, while `pretty` still fills the width, so the choice for headlines depends on the design.

  • Release Notes for Safari Technology Preview 243

    WebKit mediumAdept

    Safari Technology Preview 243 ships WebKit changes 310600@main through 312007@main for macOS Tahoe and Sequoia. The bulk of the release is CSS layout and selector fixes, covering flexbox, grid, aspect-ratio, anchor positioning, `:has()` invalidation and CJK line breaking. It also adds `contain: style` for quote counters, the `insert` keyword for `text-autospace` and the `shadowrootslotassignment` attribute. Other changes include accessibility fixes for VoiceOver, an O(n²) fix for parsing large `<select>` lists, an ES module loader rewrite for top-level await correctness, and several regular expression fixes.

  • New to the web platform in June

    web.dev easyNovice

    Chrome 149, Chrome 150 and Firefox 152 reached stable in June 2026. The headline change is that `field-sizing` and the `rect()`/`xywh()` shapes in `shape-outside` are now Baseline across all major engines. Chrome also adds CSS `text-fit`, gap decorations for grid and flex, `background-clip: border-area`, Promise-returning scroll methods, the declarative `focusgroup` attribute, and bfcache eligibility for pages with open WebSockets. Firefox adds interim and final response-header timing in Resource Timing and notification action buttons, while the Firefox 153 and Safari 27 betas preview features such as `Error.stackTraceLimit`, `getAllRecords()`, transform-aware anchor positioning and the `:heading` pseudo-class.

  • WebKit Features in Safari 17.5

    WebKit mediumAdept

    Safari 17.5 ships seven features and 22 bug fixes, led by CSS additions: text-wrap: balance (with the text-wrap-style longhand), the light-dark() color function, @starting-style for entry transitions, and supports() conditions on @import rules. WebKit balances an unlimited number of lines, versus 6 in Chromium and 10 in Firefox, but skips balancing around floats, initial letters, preserved tabs and soft hyphens. Unsupported text-wrap values fall back to auto, so they are safe to use as progressive enhancement. The release also adds AV1 in WebCodecs when a hardware decoder is available, two WebGL extensions, and fixes across accessibility, media, rendering, Web Push and WebRTC.

  • WebKit Features in Safari 16.4

    WebKit mediumAdept

    Safari 16.4 ships 135 new web features and over 280 polish updates. The headline additions are Web Push and the Badging API for Home Screen web apps on iOS and iPadOS, Declarative Shadow DOM and ElementInternals for Web Components, and a large batch of CSS features. The CSS work includes margin-trim, lh/rlh units, font-size-adjust, Relative Color Syntax, @property, Media Queries level 4 range syntax and CSS Typed OM. JavaScript gains RegExp lookbehind, and HTML gains lazy-loaded iframes. Most features come with short code examples showing typical usage.

The quest for software engineering knowledge.

Look:
Layout: