Cascading Style Sheets/Shorthand Properties

Class and ID Selectors

Use shorthand syntax for classes and longhand syntax for IDs to avoid setting unnecessary defaults and simplify debugging of dynamic class changes through scripting or property changes through pseudo-classes

Background Property Shorthand

When using shorthand to set all background properties in one declaration, use the following order for consistency and compatibility across browsers:

  1. background-color
  2. background-image
  3. background-repeat
  4. background-attachment
  5. horizontal position
  6. vertical position

Use background-image instead of the background shorthand when using ID selectors to avoid inadvertently overriding class-based background-position changes for CSS sprites

List-Style Shorthand

Use list-style shorthand instead of list-style-type for IE6 to avoid the declaration being ignored by the CSS parser