W3C home > Mailing lists > Public > www-style@w3.org > January 2012

Re: @important instead of multiple !important

From: Marat Tanalin | tanalin.com <mtanalin@yandex.ru>
Date: Fri, 06 Jan 2012 02:52:42 +0400
To: juancarlospaco@ubuntu.com
Cc: www-style@w3.org
Message-Id: <500991325803962@web57.yandex.ru>
06.01.2012, 02:38, "Juan Carlos Ojeda" <juancarlospaco@gmail.com>:
> On Thu, Jan 5, 2012 at 7: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;
>> š š š š š š š š}
>> š š š š}
>>
>> Thanks.
>>
>> P.S. Just in case: DRY is abbreviation from "Don't Repeat Yourself".
>
> And what about:
>
> #statusbar-display.* { !important }

Looks like a too strong deviation from current CSS syntax.
For the purpose of important'ing all properties of a _single_ separate rule, we could have 'important' property:

	#statusbar-display {
		left:  0;
		right: auto;
		important: true;
	}

that would have same result as:

	#statusbar-display {
		left:  0 !important;
		right: auto !important;
	}
Received on Thursday, 5 January 2012 22:55:43 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:48 GMT