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-cascade-4] Add an alias to !important #9778

Open
francescorn opened this issue Jan 10, 2024 · 6 comments
Open

[css-cascade-4] Add an alias to !important #9778

francescorn opened this issue Jan 10, 2024 · 6 comments
Labels
css-cascade-4 Current Work

Comments

@francescorn
Copy link
Contributor

francescorn commented Jan 10, 2024

css-cascade-4

! is the logical not operator. When adding ! in front of important, it should mean it is not important, as in not taking precedence.

* would make more sense to be in front since it covers all of the elements.

My proposed task would be to:

  1. Add an alias for !important such as *important because it is closer to meaning more/most important of all elements.
@francescorn francescorn changed the title [css-cascade-4] Rename and reassign !important [css-cascade-4] Add an alias to !important Jan 10, 2024
@Loirooriol
Copy link
Contributor

! is the logical not operator

CSS doesn't have a logical not operator

Add an alias for !important

At this point it doesn't seem feasible to deprecate !important, so adding an alias will just increase confusion IMO.

*important

That's problematic, because that's valid in a <declaration-value>. But a top-level ! is not, so it can act as a delimiter.

In particular, this would break:

document.body.style.cssText = "--foo: bar*important";
document.body.style.getPropertyValue("--foo"); // "bar*important"

@Loirooriol Loirooriol added the css-cascade-4 Current Work label Jan 10, 2024
@astearns
Copy link
Member

It definitely is confusing, and on our list of mistakes.

It might be possible to come up with an alias that works better, but I expect this would need to be a longer keyword instead of adding some special character. And I’d like the new thing to make it more clear how important declarations interact with origins and contexts https://www.w3.org/TR/css-cascade-4/#cascade-origin

@francescorn
Copy link
Contributor Author

francescorn commented Jan 10, 2024

What about mostImportant or moreImportant?

@francescorn
Copy link
Contributor Author

@fantasai @litherum What are your thoughts on a better alias name?

@litherum
Copy link
Contributor

I’m categorically against aliases.

  • They have maintenance cost for implementers
  • They don’t offer authors any functionality that they didn’t have before
  • The web is the biggest platform in the world. As such, it is totally capable of defining its own conventions.

@Crissov
Copy link
Contributor

Crissov commented Jan 11, 2024

Do XML and HTML get the same kind of comments for having <!DOCTYPE and <!--?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-cascade-4 Current Work
Projects
None yet
Development

No branches or pull requests

5 participants