!default
declarations, opposite to !important
declarations, could set a default property value, if it has not been set yet, or if another !default
declaration is more specific. User agent styles should be overridden with !default
(of course excluding ones with !important
).
Consider this example:
<body class="default-theme new-theme">
<button>Style me!</button>
</body>
.new-theme button {
border: thin solid black;
}
button {
border: 1px dotted grey !default;
}
.default-theme button {
border: none !default;
}
The button would have a thin solid black border in result. Having the !default
declaration possible would make it so much easier to do theming or reset CSS.
I don't like !important
very much, and this would be a similar hack. And I don't think it's necessary, because you should be able to achieve a similar behavior by using selectors with 0 specificity (#1170), e.g.
:is(.default-theme button) {
border: none; /* default */
}
Just want to point out some implications of using !default
vs. :is()
:
!default
takes the specificity into account, :is()
does not!default
applies to individual properties, :is()
to the whole rule!important
annotation untouchedSebastian
Most helpful comment
Just want to point out some implications of using
!default
vs.:is()
:!default
takes the specificity into account,:is()
does not!default
applies to individual properties,:is()
to the whole rule!important
annotation untouchedSebastian