CSSLint / csslint

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

Proposed Warning: img with width:100% or width:auto #714

Open joyously opened 6 years ago

joyously commented 6 years ago

Any rule with img at the end of a selector can have two problems.

  1. width:auto - CSS rules override HTML attributes. The default for width is auto, so by specifying it, the HTML attribute will be ignored.

  2. width:100% - This is only valid when the parent width is known to be less than or equal to all child images, which would be a rare case. Otherwise, images get upscaled by the browser and not only look bad, but the HTML width attribute is ignored.