[csswg-drafts] How do custom origins interact with `!important`? (#4971)

mirisuzanne has just created a new issue for https://github.com/w3c/csswg-drafts:

== How do custom origins interact with `!important`? ==
This is in relation to #4470 custom-origin proposal.

The predefined origins are stacked such that important origins reverse the order of their normal counterparts:

- !important
 - User Agent
 - User
 - Author
- normal
 - Author
 - User
 - User Agent

## Not Intertwined:

When adding custom origins (really a subset of the author origins) – I think it’s clear that important and normal styles cannot not be intertwined:

- Author Origin 2
 - !important
 - normal
- Author Origin 1
 - !important
 - normal

That would not be compatible with the existing model. The `!important` flag is not meant for that kind of internal layering (we have specificity for that), but for balancing power between origins.

## Reverse or maintain order?

It’s less clear if reverse-ordering should be maintained, or if that should be customizable. When origins are static and represent different concerns, the reversal ensures that lower origins can get final say when necessary. Since custom origins are not pre-set, and new origins could be added at either end, I think: 

- **Neither approach is dangerous.** If a third-party framework provides both normal and important styles, I can work within either framework to override what I want as an author. I can create origins below or above, and add `!important` flags in either case. Because of that, I’m also not sure there’s a strong need for user-customization of the important oder, which would add both inconsistency between projects, and additional syntax. 
- **Reversed order is consistent with existing origins.** If custom origins worked the same way, it might help teach the concept. I'm not sure this approach has much else going for it in use-cases I've seen.
- **Maintained order matches current author experience.** Because author normal & important layers are side-by-side, authors rarely think about other origins, let alone reversal of important layers. Adding `!important` feels more like a linear change in specificity.  This is much more likely expected behavior.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4971 using your GitHub account

Received on Saturday, 18 April 2020 23:32:28 UTC