CSS Tips

Grouping Selectors

Keeping your CSS light is important to minimize download times. CSS allows you to group multiple selectors that share the same declaration. As much as possible, group selectors, rely on inheritance, and reduce redundancy by using shorthand. Grouping allows the author to assign a single style declaration to multiple elements (selectors).

So this:

#content {border:1px solid green;}
#nav {border:1px solid green;}

Becomes this:

#content, #nav { border:1px solid green;}

For more information visit:

<< previous | next >>