8000 [css-variables][css-pseudo] Question about setting variable values in pseudo classes · Issue #10778 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-variables][css-pseudo] Question about setting variable values in pseudo classes #10778

@xgebi

Description

@xgebi

My colleague and I are trying to figure out if this is a browser bug (in all browsers) or an exception in a standard.

Let's say we have HTML

<a href="https://codepen.io/">Codepen</a>

and CSS

:root {
  --color: red;
}

a {
  color: var(--color);
}

a:hover {
  --color: green;
}

a:visited {
  --color: purple;
}

As the link is visited and last setting of --color is purple, the color of the text in the link should be purple. Except it's not, it remains red.

If this behavior with :visited was consistent with all pseudo-classes, I wouldn't question it as in the spec is written that variables apply to all elements and all pseudo-elements. On hover the text turns green with the code above in Firefox, Chrome and Safari.

Codepen example

My question is, is ignoring the setting of --color in a:visited a standards bug or should we make reports to browsers' issue trackers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.Commenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.css-pseudo-4Current Work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0