Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(css): update universal selector case #34241

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

OnkarRuikar
Copy link
Contributor

@OnkarRuikar OnkarRuikar requested a review from a team as a code owner June 18, 2024 04:20
@OnkarRuikar OnkarRuikar requested review from estelle and removed request for a team June 18, 2024 04:20
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/s 6-50 LoC changed labels Jun 18, 2024
Copy link
Contributor

github-actions bot commented Jun 18, 2024

Preview URLs

(comment last updated: 2024-06-19 06:32:42)

@OnkarRuikar OnkarRuikar marked this pull request as draft June 18, 2024 04:29
@OnkarRuikar OnkarRuikar marked this pull request as ready for review June 18, 2024 04:37
@github-actions github-actions bot added size/xs 0-5 LoC changed and removed size/s 6-50 LoC changed labels Jun 18, 2024
@OnkarRuikar OnkarRuikar changed the title fix(css): add universal selector case fix(css): update universal selector case Jun 18, 2024
@estelle
Copy link
Member

estelle commented Jun 18, 2024

In this case, we should have gone with option 2, "The page on Child combinator should mention what would happen if selector1 is absent." The universal selector is implied, and would not be added by a CSS developer in these cases, so should not be added in these examples. Instead, we should teach people that the universal selector is implied.

@lalaniArman
Copy link

@estelle I tried a simple example to verify if the universal selector is implied. It doesn't seem to work. Please check it out here - https://codepen.io/lalaniArman/pen/JjqpJzG
Am I missing anything?

@Josh-Cena
Copy link
Member

@estelle: I don't think relative selectors are valid in complex selector lists. They are only valid inside :has. This was what I fixed a while ago in #34045

@github-actions github-actions bot added size/s 6-50 LoC changed and removed size/xs 0-5 LoC changed labels Jun 19, 2024
@OnkarRuikar
Copy link
Contributor Author

The universal selector is implied, and would not be added by a CSS developer in these cases, so should not be added in these examples. Instead, we should teach people that the universal selector is implied.

@estelle If you workout the grammar from <combinator> you'll find that * > p is a complex-selector and > p is a relative-selector and they are not the same. Relative selector works only in certain contexts like :has(>p).

If you put following code in https://jigsaw.w3.org/css-validator/#validate_by_input+with_options it says >p is invalid:

* > p {
  font-size: 1rem;
}

:has(> p) {
  font-size: 2rem;
}

> p {
  font-size: 3em;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs size/s 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The first selector is missing with the child combinator used in the example CSS file
4 participants