To many !important declarations as an Error? #105

cssagogo opened this Issue Jul 6, 2011 · 4 comments


None yet

3 participants

cssagogo commented Jul 6, 2011

Should this be an error or just an alert? Seems like more of an alert to me.

Error   (rollup)    (rollup)    
Important   Too many !important declarations (52), be careful with rule specificity
undefined  All
nzakas commented Jul 7, 2011

We only have two designations: warnings and errors. Each instance of !important is a warning and if you have a bunch, it's an error.

cssagogo commented Jul 7, 2011

Hmm...maybe its just a mater of semantics, but to me an error is something that will break the CSS. Something like a missing closing bracket, unknown/misspelled attribute name/value, unknown selector. Although to many !important rules are frowned upon it will not break anything if done right. In my case I have a series of quick override classes to zero out margins, padding, borders, rounded corners and another series to float elements left and right and another for text alignment. I use !important on each.

/* No Border (Removes)
=================================== */
.sNBT {border-top:0 !important}
.sNBR {border-right:0 !important}
.sNBB {border-bottom:0 !important}
.sNBL {border-left:0 !important}

/* No Rounded Corners (Removes)
=================================== */
.sNRCB {-webkit-border-bottom-left-radius:0 !important;-webkit-border-bottom-right-radius:0 !important;-moz-border-radius-bottomleft:0 !important;-moz-border-radius-bottomright:0 !important;border-bottom-left-radius:0 !important;border-bottom-right-radius:0 !important}
.sNRCL {-webkit-border-bottom-left-radius:0 !important;-webkit-border-top-left-radius:0 !important;-moz-border-radius-bottomleft:0 !important;-moz-border-radius-topleft:0 !important;border-bottom-left-radius:0 !important;border-top-left-radius:0 !important}
.sNRCT {-webkit-border-top-right-radius:0 !important;-webkit-border-top-left-radius:0 !important;-moz-border-radius-topright:0 !important;-moz-border-radius-topleft:0 !important;border-top-right-radius:0 !important;border-top-left-radius:0 !important}
.sNRCR {-webkit-border-top-right-radius:0 !important;-webkit-border-bottom-right-radius:0 !important;-moz-border-radius-topright:0 !important;-moz-border-radius-bottomright:0 !important;border-top-right-radius:0 !important;border-bottom-right-radius:0 !important}

/* No Margins (Removes)
=================================== */
.sNMT {margin-top:0 !important}
.sNMR {margin-right:0 !important}
.sNMB {margin-bottom:0 !important}
.sNML {margin-left:0 !important}

/* Margins (Adds To)
=================================== */
.sMTsm {margin-top:12px !important}
.sMBsm {margin-bottom:12px !important}
.sMTlg {margin-top:24px !important}
.sMBlg {margin-bottom:24px !important}

/* No Padding (Removes)
=================================== */
.sPT {padding-top:0 !important}
.sPR {padding-right:0 !important}
.sPB {padding-bottom:0 !important}
.sPL {padding-left:0 !important}

/* Floats (Adds To)
=================================== */
.sFL {display:inline !important;float:left !important}
.sFR {display:inline !important;float:right !important}

/* Text Alignment (Adds To)
=================================== */
.sAL {text-align:left !important}
.sAC {text-align:center !important}
.sAR {text-align:right !important}
nzakas commented Jul 12, 2011

I can understand that line of reasoning. There are generally two schools of thought about errors. First is, as you said, a parsing error that will absolutely break if not fixed. The second is that plus "hey, we've warned you a bunch of times and you should be careful about this." I can personally go either way. Nicole, what do you think?

@stubbornella stubbornella was assigned Jul 12, 2011
nzakas commented Jul 12, 2011

Okay, we'll change the rollup to a warning from an error.

@nzakas nzakas pushed a commit that closed this issue Jul 12, 2011
Nicholas C. Zakas Changed too many \!important error to a warning (fixes #105) 656d8ae
@nzakas nzakas closed this in 656d8ae Jul 12, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment