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

[css-selectors] Support universal selector usage with tagname *tagname #8392

Closed
brandonmcconnell opened this issue Feb 1, 2023 · 1 comment

Comments

@brandonmcconnell
Copy link

brandonmcconnell commented Feb 1, 2023

Currently, all/most selectors support use after the universal selector.

For example…

w/ universal selector w/o universal selector identical targeting
*.class .class
*#id #id
*[attribute] [attribute]
*:pseudo :pseudo
*::pseudo ::pseudo
*elem elem

Some advantages to allowing the universal selector to prepend tagname selectors are:

  • better consistency in how all selectors behave with the universal selector

  • easier nesting syntax agreed upon nesting syntax

    Up until now, the generally accepted and voted upon nesting syntax requires wrapping a selector with something like :is() or :where() when it begins with an alpha character since that could easily be confused with a CSS property name. That can look something like this:

    a:hover {
      color: hotpink;
      :is(aside) & {
        color: red;
      }
    }

    With this change to how the universal selector works next to tagnames, this same block could now be rewritten much more concisely using * like this:

    a:hover {
      color: hotpink;
      *aside & {
        color: red;
      }
    }

I put together a pen for this which can be used for demonstrating this proposal and also to test if/when this is implemented:
https://codepen.io/brandonmcconnell/pen/eYjYVrE

@brandonmcconnell brandonmcconnell changed the title Support using universal selector with tagname [css-selectors] Support universal selector usage with tagname *tagname Feb 1, 2023
@Loirooriol
Copy link
Contributor

Duplicate of #8253.

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

No branches or pull requests

2 participants