Require shorthand properties
Hubert SABLONNIÈRE edited this page May 23, 2013
·
3 revisions
Pages 49
- Home
- About
- Avoid un anchored hovers
- Beware of box model size
- Build System
- Build System Integration
- Bulletproof font face
- Command line interface
- Contributing
- Developer Guide
- Disallow !important
- Disallow @import
- Disallow adjoining classes
- Disallow box sizing
- Disallow duplicate background images
- Disallow duplicate properties
- Disallow empty rules
- Disallow IDs in selectors
- Disallow negative text indent
- Disallow non alphabetical
- Disallow outline:none
- Disallow overqualified elements
- Disallow qualified headings
- Disallow selectors that look like regular expressions
- Disallow star hack
- Disallow too many floats
- Disallow underscore hack
- Disallow units for zero values
- Disallow universal selector
- Disallow unqualified attribute selectors
- Don't use too many font size declarations
- Don't use too many web fonts
- Headings should only be defined once
- IDE integration
- Ignoring parts of CSS during linting
- New Release
- Require all gradient definitions
- Require compatible vendor prefixes
- Require fallback colors
- Require properties appropriate for display
- Require shorthand properties
- Require standard property with vendor prefix
- Require use of known properties
- Rules
- Rules by ID
- Source Code
- Unit Tests
- Using in a Node.js Application
- Working with Rules
- Show 34 more pages…
Clone this wiki locally
Sometimes when editing a rule you may end up defining multiple properties that can better be represented using shorthand. For example:
.mybox {
margin-left: 10px;
margin-right: 10px;
margin-top: 20px;
margin-bottom: 30px;
}These four properties can actually be combined into a single margin property, such as:
.mybox {
margin: 20px 10px 30px;
}Using shorthand properties where possible helps to decrease the overall size of the CSS.
Rule Details
Rule ID: shorthand
This rule is aimed at decreasing file size by finding properties that can be combined into one. As such, it warns in the following cases:
- When
margin-left,margin-right,margin-top, andmargin-bottomare used together in a single rule. - When
padding-left,padding-right,padding-top, andpadding-bottomare used together in a single rule.
The following patterns are considered warnings:
.mybox {
margin-left: 10px;
margin-right: 10px;
margin-top: 20px;
margin-bottom: 30px;
}
.mybox {
padding-left: 10px;
padding-right: 10px;
padding-top: 20px;
padding-bottom: 30px;
}The following patterns are considered okay and do not cause warnings:
/* only two margin properties*/
.mybox {
margin-left: 10px;
margin-right: 10px;
}
/* only two padding properties */
.mybox {
padding-right: 10px;
padding-top: 20px;
}Automated linting of Cascading Stylesheets