Quick Tip 5 – Compact CSS

Are you finding that sometimes you are writing out the same rules multiple times for classes, id’s or tags?

A very simple tip today, but one that can help dramatically reduce the amount of CSS Styles you create.

This, For Example:


.col_1 { width: 330px; height: 400px; padding: 20px; background: #ccc; }
.col_2 { width: 330px; height: 400px; padding: 20px; background: #666; }
.col_3 { width: 330px; height: 400px; padding: 20px; background: #999; }

Quick Tip Gary
Should Be:


.col_1, .col_2, .col_3 { width: 330px; height: 400px; padding: 20px; }
.col 1 { background: #ccc; }
.col 2 { background: #666; }
.col 3 { background: #999; }

Therefore you no longer have to repeat any code that has already been assigned.

Related posts:

  1. Quick Tip 6 – CSS Shorthand
  2. Quick Tip 7 – CSS !Important
  3. Quick Tip 9 – CSS min height
  4. Quick Tip 2 – CSS Text Shadow
  5. Quick Tip 10 – CSS Vertical Alignment

Tags: , ,

Leave a Reply

Contact Us Today...

For more information regarding any of our services or to arrange a free consultation simply send us a message or call 02920 290 080 for Cardiff and 01179 000 482 for Bristol.

Firefox 4 Beta

Mozilla have released the first beta version of Firefox 4. The latest version of this browser will include better support for many of the new web technologies, a new add on manager, crash protection from third party plugins and accelerated hardware support. One of the most obvious changes is that the tabs have now been moved [...]
» more

Cardiff: 02920 290 080 Bristol: 01179 000 482