Re: [csswg-drafts] [css-color-adjust-1] more granular overriding of forced colors mode than per-element (#4178)

OK, building on Tab's three options for interpreting a `!override-forced-colors`, one thing to think about is how they interact with the media query:

- In (1), if you used the override outside of a `(forced-colors: active)` media query, it would behave as a `!super-important` when the browser isn't in forced colors mode.

  This seems like a potential for misuse, throw it on when you need to override a 3rd-party library's `!important` style, without testing for what it actually does in forced color mode.

- In (3), the media query would become completely optional unless you also wanted to adjust other properties, as the `!override-f-c` would act as a declaration-scoped media query condition itself.

  E.g., the following would always have a red border, but the text color would be purple in normal mode (because of regular positional cascade) and the `highlightText` color in forced color mode (because of forced color mode triggering the super important behavior):

  ```css
  .selector {
    border: thick solid red !override-forced-colors;
    color: highlightText !override-forced-colors;
    color: purple;
  }
  ```

- In (2), the media query would be optional if you wanted to force your normal style to stay the same in forced-color mode, but it would be required if you want to define your own color overrides.  Which seems like a nice compromise to me.

  The previous example would become:

  ```css
  .selector {
    border: thick solid red !override-forced-colors;
    color: purple;
  }
  @media (forced-colors: active) {
    .selector {
      color: highlightText !override-forced-colors;
    }
  }
  ```  

  The only downside is one that is shared with all media queries: the MQ doesn't add any specificity or importance to the declaration, so authors still need to make sure that the MQ rules override the basic rules when the MQ is active.

In all of these cases, if you do use the media query, you'd probably need a big long line of `!override-f-c` modifiers on every declaration inside the MQ block.

In contrast, the way the original `-ms-` prefixed media query worked is that by the nature of being contained inside that MQ block, declarations had special importance given to them. I'm not sure of how that special importance worked in its interactions with the rest of the cascade, but it's worth considering whether it would be possible to recreate some of that simplicity.

Maybe a media query that is activated by forced colors mode could implicitly get the `!override-f-c` behavior for all of its declarations. Or maybe there could be a new syntax way of setting a `!` modifier on a media query block as a whole.

-- 
GitHub Notification of comment by AmeliaBR
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4178#issuecomment-608119865 using your GitHub account

Received on Thursday, 2 April 2020 22:16:24 UTC