CSSLint / csslint

Automated linting of Cascading Stylesheets
http://csslint.net
Other
4.77k stars 483 forks source link

Box model rule alerts when width or height are set to auto #287

Closed menzer closed 12 years ago

menzer commented 12 years ago

The purpose of the box model rule is to alert the author to potentially unforeseen sizes due to the box model when width or height declarations are combined with other box-model declarations. But if the width or height declaration is overriding a set value and returning to auto, in an OOCSS extension for example, then a padding or border declaration should not trigger the box alert rule, as there is explicitly no expected height or width on the element.

mahonnaise commented 12 years ago
.foo {
  padding: 5px;
  width: auto;
}

This does indeed trigger a warning. I agree that it shouldn't. It actually shouldn't trigger a warning whenever the value isn't a <length/percentage>. [There are a bunch of other possible values].

[Side note: I recommend to disable this rule, because it's actually not very helpful. It's supposed to detect a glaringly obvious defect, which hits you right in the face when you produce it. When it doesn't tell you something you've already noticed yourself a few minutes ago, it will just waste your time with false positives. I.e. you did the math and you get indeed the results you were after.]

nzakas commented 12 years ago

Makes sense. So basically, it should warn only when width or height is a <length> or <percentage> and otherwise not.

mahonnaise commented 12 years ago

"Don't use width or height when using padding or border."

Will need some rephrasing, too.