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

Re: @important instead of multiple !important

From: Jeffrey Way <jeffrey@envato.com>
Date: Thu, 5 Jan 2012 19:25:26 -0500
To: "Marat Tanalin | tanalin.com" <mtanalin@yandex.ru>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, www-style@w3.org
Message-ID: <4AE80F51A4434B6EAD3AE4DEE28F0236@envato.com>
!important is essentially a way to say, "screw you, cascade." Yes, it does have its place in user stylesheets and maybe for bullet-proof classes (I've never used it in that way though), but it shouldn't be recommended in 99.8% of cases. I could be wrong, but my instinct is that the number of people who make use of "user-stylesheets" is incredibly low, so it seems a bit silly to introduce a new way to apply !important to a block of code for that purpose alone. 

> Considering your point, shortening '!important' to '!' (while being not so DRY as @important would be) would have similar result: "encourage newcomers to use and abuse it".
Replacing !important with ! is not encouraging anything, and it's not introducing additional functionality.

Jeffrey 


On Thursday, January 5, 2012 at 7:18 PM, Marat Tanalin | tanalin.com wrote:

> Considering your point, shortening '!important' to '!' (while being not so DRY as @important would be) would have similar result: "encourage newcomers to use and abuse it".
> 
> 
> 06.01.2012, 04:10, "Jeffrey Way" <jeffrey@envato.com (mailto:jeffrey@envato.com)>:
> > The problem is that, if introduced, it *really* encourages newcomers to use and abuse it. The potential uses are so rare that it doesn't seem necessary. More bad good potentially come from it than good.
> > I'm in favor of: prop: val !;
> > Jeffrey
> > 
> > On Thursday, January 5, 2012 at 7:03 PM, Marat Tanalin | tanalin.com (http://tanalin.com) wrote:
> > > 06.01.2012, 03:48, "Tab Atkins Jr." <jackalmage@gmail.com (mailto:jackalmage@gmail.com)>:
> > > > 2012/1/5 Marat Tanalin | tanalin.com <mtanalin@yandex.ru (mailto:mtanalin@yandex.ru)>:
> > > > >  06.01.2012, 03:30, "Tab Atkins Jr." <jackalmage@gmail.com (mailto: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 02:03:46 GMT

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