Transparent text when selected

Chromium issue 41228297 | CL 8456516 | status: open

There are two separate behaviors for transparent (color: transparent) text under a selection. They are easy to conflate, so this sampler keeps them apart. Use the button to select everything, then look at each sample.

Case 1 — UA default selectionfixed by CL 8456516

No author ::selection color or background

The page sets only color: transparent and never styles ::selection. The selection highlight and its foreground come entirely from the UA. On macOS the UA historically supplied no selection foreground (SupportsSelectionForegroundColors() is false), so the glyphs stayed transparent and the selection looked empty. On Windows and Linux the UA already supplies a foreground, so the text was always visible.

CL 8456516 makes macOS fall back to the UA selection foreground when the originating color is fully transparent, matching Windows/Linux. This is the actual issue from 2015.

Live browser rendering; select the sample below

Transparent text should remain readable when selected.

Case 2 — author sets ::selection { background } onlypaired defaults, not changed

Author background, no author ::selection color

Here the author sets ::selection { background: #3875d7 } but no color. Per the paired-defaults rule, specifying one of the pair suppresses the UA default for the other, so the unspecified color resolves to currentColor (the transparent originating color). The selected text stays invisible.

This reproduces identically on Windows, macOS, and Linux (confirmed Chrome 156 / Edge 152), and it is spec-correct. CL 8456516 intentionally does not change this case: an author background sets HasAuthorHighlightColors(), which skips the UA default-foreground path entirely. Removing the ::selection background turns this back into Case 1.

Live browser rendering; select the sample below (stays invisible by design)

Transparent text selected.

Expected result for Case 1

Reference for the fixed selection rendering

Transparent text should remain readable when selected.

macOS screenshots (Case 1, before the fix)

Captured on macOS Chrome 153

The actual screenshot shows the selection highlight with no visible glyphs. The expected screenshot shows the intended readable foreground.

Actual browser screenshot · Expected screenshot · Browser screenshot

Actual macOS Chrome rendering: selection highlight without visible textExpected selection rendering with legible text

WPT coverage in the CL