Skip to content

[css-pseudo] should all highlights have paired defaults? #7837

Closed

Description

@delan

#6386 asked a bunch of questions about paired defaults, which is the compat behaviour where the UA default ::selection ‘color’ and ‘background-color’ (‘HighlightText’ and ‘Highlight’) are only used when neither were set by the author.

In particular, question 3 asks whether this should apply to the other highlights too, and this issue is meant to resolve that question. Currently ::target-text is the only pseudo with defaults for those properties (‘MarkText’ and ‘Mark’), so it’s the only pseudo that’s affected by this issue.

One reason to say no is that ::target-text doesn’t have the legacy of ::selection that made this rule necessary. One reason to say yes is consistency, since the highlights are already a complicated enough pile of exceptions without adding an exception for just one of them. Another is that the behaviour can be useful for the same reasons it is for ::selection, that is, avoiding situations where the author setting only one of the properties yields an illegible result in another browser with different defaults.

(see also: fantasai’s comment, my comment, emilio’s comment)

Activity

  1. astearns commented on Nov 23, 2022

    @astearns
    Member

    The bot missed adding the minutes. Here’s a hand-edited version:

    RESOLVED: paired defaults apply to all highlights

    The full IRC log of that discussion

    Topic: Paired defaults
    delan: This issue won't affect implementation complexity much, about what makes sense to authors
    delan: some highlight pseudos have default background color and default color
    delan: e.g. ::selection has default colors
    delan: and ::target-text
    delan: but it's not true for e.g. spelling/grammar error, where default styles add squiggly lines but don't change colors
    delan: ::selection has special behavior called "paried defaults"
    delan: rule is there for compat reasons
    delan: means that those default colors only get used
    delan: if neither color nor background was set by the author
    delan: beside compat, has some other benefits
    delan: prevents illegible combination of colors
    delan: e.g. some browsers have light text for selections, and some have dark text
    delan: so question is, should these apply to other highlight types?
    delan: or only to ::selection?
    florian: Point about default colors being relied on makes sense, so I would say yes it should apply to all
    emilio: Gecko doesn't have this magic if the author specifies selection styles
    1emilio: do you know the state of interop?
    1delan: it's also in Gecko
    1emilio: if you specify ::selection { background: green ; color: green; } we wouldn't magically infer the color
    1delan: that's separate
    delan: this is if the author only sets one of these properties, does it get the UA color or does it get transparent/currentcolor
    delan: inverting is a separate issue
    florian: If we don't do it we have a risk of browser-dependent illegible things, and that's bad
    fantasai: I think propsoed resolution is, do we apply paired defaults to all highlights
    fantasai: so do we have any objections? if not we can resolve
    delan: so resolution is that they would apply to all fo the highights?
    florian: we have delan, fantasai, and myself agreeing and nobody is pushing back
    Rossen_: I'm not hearing any objections, so let's resolve
    Rossen_: if anyone thinks about this we can come back and change if necessary
    RESOLVED: paired defaults apply to all highlights

  2. delan commented on Nov 24, 2022

    @delan
    ContributorAuthor

    #6665 assumed we would resolve in favour of ::target-text using paired defaults (see this thread), so no edits needed :)

    Some highlight pseudo-elements should have paired default highlight colors—a default color and background-color provided by the UA that are either used or overridden together, see § 3.3.1 Paired Defaults. For ::selection they should correspond to HighlightText and Highlight, while for ::target-text they should correspond to MarkText and Mark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions