Add data for CSS Highlight Inheritance (::selection, ::target-text)

Open
#30,951 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
css, json
Domain
data

Research direction

Start with css/selectors/selection.json and the existing text-decoration subfeature. Compare the proposed inheritance entry with the spec and linked Chrome and Mozilla reports to establish browser version data, including Chrome’s removal and re-enablement. Done when the ::selection and ::target-text compatibility data captures the inheritance behavior and is consistent with the confirmed browser support.

Written by the indexing model from the issue text.

Description

needs triage
What type of issue is this?

Missing compatibility data

What information was incorrect, unhelpful, or incomplete?

BCD has no entry for CSS highlight inheritance. So, the ::selection compat table can not show that browsers differ on this behavior.

In browsers that implement the spec’s highlight inheritance model, a child’s ::selection inherits from its parent’s ::selection. In browsers that don’t, it uses the older originating-element model. This changes the result of the example in MDN’s Pseudo-elements article in Firefox. Selected text in the child stays green instead of inheriting red from the parent.

In Firefox:
Image

Current state of support, as far as I can tell:

  • Chrome: the Chrome blog says the change shipped in 131, was removed because of compatibility issues, and was re-enabled in 134 for ::selection and ::target-text

  • Firefox: not implemented. Mozilla bug [also check the bug cited in #22218]

  • Safari: I did not test for it.

Spec: https://drafts.csswg.org/css-pseudo-4/#highlight-cascade

What browsers does this problem apply to, if applicable?

Firefox

What did you expect to see?

A compat entry for CSS highlight inheritance under ::selection (and ::target-text), so the table shows which browsers use the spec’s highlight inheritance model (a child’s ::selection inherits from its parent’s ::selection) and which still use originating-element inheritance. Firefox should be listed as not supporting it (version_added: false), with Chrome’s support starting in the version the data confirms (the Chrome blog says 134, after a removal from 131).

In Chrome / Brave:

Image
Did you test this? If so, how?

Yes. I ran the example from MDN’s Pseudo-elements article in Firefox [v158.0] and Chrome [v155.0] / Brave [v155.1].
In Chrome and Brave, selected text in the child inherits red from the parent’s ::selection. In Firefox, the child’s selected text stays green because it inherits from the child element instead.

I did not test for Safari.

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?
Do you have anything more you want to share?

Related History: #22218 proposed this data but was closed unmerged, apparently because Chrome’s status changed. MDN content issues #44722 and #36458 discuss the documentation side, and #44722 points to BCD as the place for browser differences.

Proposal: Add an inheritance subfeature, following the structure of #22218 and the existing text-decoration subfeature in css/selectors/selection.json.

Questions:

  • How should Chrome’s 131 release and removal be recorded, versus 134?

  • Is this the right structure? I’m happy to submit a PR once you confirm.

MDN URL

No response

MDN metadata

No response

Dominant language
JSON
Stars
5.8k
Forks
2.7k
Avg merge
2d 20h
Merged PRs (30d)
160

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mdn/browser-compat-data

All issues in mdn/browser-compat-data

Similar issues

More Data Engineering issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.