Re: @important instead of multiple !important

06.01.2012, 03:30, "Tab Atkins Jr." <jackalmage@gmail.com>:
> On Thu, Jan 5, 2012 at 2:29 PM, Marat Tanalin | tanalin.com
> <mtanalin@yandex.ru> wrote:
>
>> šWriting user stylesheets, we're often forced to add "!important" after value of each property (generally, the proposal should not be limited to user stylesheets though).
>>
>> šIt would be much more usable and DRY to have at-rule of the same name to prevent redundant multiple "!important" word duplication.
>>
>> šFor example, currently we write:
>>
>> šš š š š#statusbar-display {
>> šš š š š š š š šleft: š0 !important;
>> šš š š š š š š šright: auto !important;
>> šš š š š}
>>
>> šš š š š#statusbar-display .statuspanel-label {
>> šš š š š š š š šborder-left-style: šnone !important;
>> šš š š š š š š šborder-right-style: solid !important;
>> šš š š š}
>>
>> šInstead we could wrap the rules to one @important rule, thus avoiding repeating "!important" multiple times:
>>
>> šš š š š@important {
>> šš š š š š š š š#statusbar-display {
>> šš š š š š š š š š š š šleft: š0;
>> šš š š š š š š š š š š šright: auto;
>> šš š š š š š š š}
>>
>> šš š š š š š š š#statusbar-display .statuspanel-label {
>> šš š š š š š š š š š š šborder-left-style: šnone;
>> šš š š š š š š š š š š šborder-right-style: solid;
>> šš š š š š š š š}
>> šš š š š}
>
> !important is *almost always* a bad idea in author stylesheets, and I
> don't want to support anything making it more convenient.

!important _is_ used in real world anyway.

> You're right, though, that it's often necessary to put !important on
> every single declaration in user stylesheets. šPerhaps we can solve
> this in an easier way. šFor example, asking browser vendors to support
> two user stylesheets, one of which is processed normally and the other
> which is automatically placed in the user!important level (wherein
> !important wouldn't do anything).
>
> This way you can easily distinguish en-masse between setting your own
> defaults (the use of the normal user level) and overriding the page's
> styles (the use of the user!important level).
>
> ~TJ

Do you mean that we will then be forced to have two separate CSS files?

If so, it would be not as usable as @important rule would be since latter would allow to put all user styles in one stylesheet.

Received on Thursday, 5 January 2012 23:44:26 UTC