Re: @important instead of multiple !important

06.01.2012, 03:48, "Tab Atkins Jr." <jackalmage@gmail.com>:
> 2012/1/5 Marat Tanalin | tanalin.com <mtanalin@yandex.ru>:
>
>> š06.01.2012, 03:30, "Tab Atkins Jr." <jackalmage@gmail.com>:
>>> š!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.
>
> Yes, so I wouldn't advocate removing it entirely (even if I think it
> would probably be a good idea). šI'm just saying that I don't want to
> make it *easier* to use !important in author stylesheets.

Sounds somewhat odd for me. There are cases where it's needed to override previous rules exactly once, thus not resulting in any bad consequences as for specificity. Grouping such rules inside @important rule would improve readability of CSS code in such cases.

>>> š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).
>> š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.
>
> Sure, it would be less convenient in some ways. šIt's also better in
> some ways - it cleanly distinguishes between the two uses that user
> stylesheets are put to.
>
> Importantly, though, it requires zero additions to the CSS language.
> Given that user stylesheets are important but niche, finding solutions
> that don't involve expanding the language is somewhat valuable.
>
> ~TJ

A probable usable option is to add @important to CSS spec but limit its application to user stylesheets only.

Received on Friday, 6 January 2012 00:06:59 UTC