It’s important to keep a consistant style when writing CSS. When you have a team of developers you might want to consider writing a guideline that everyone follows.

Here are some guidelines I follow…

  1. Always combine statements that can be combined. One line is shorter and sweeter. It groups all statements of the same type together which is useful and easier to access. For example:
    /* Better */
    background: url(background.png) #00FF00 no-repeat;
    
    /* Bad */
    background-image: url(background.png);
    background-color: #00FF00;
    background-repeat: no-repeat;
    
  2. Always use words for colours where possible. If you’re dealing with a basic developer they’re far more likely to recognise the word of the colour than the hex value.
    /* Better */
    color: white;
    
    /* Bad */
    color: #FFFFFF;
    
  3. Shorten hex colours where possible. Short and sweet.
    /* Better */
    color: #F0F;
    
    /* Bad */
    color: #FF00FF;
    
  4. Hex values are easier to spot and read when in capitals.
    /* Better */
    color: #F0F;
    
    /* Bad */
    color: #f0f;
    
  5. All hacks should be linked to documentation in a comment. Hacks can be pretty confusing looking to many CSS developers, so why not do them a favour and link them to some relevant documentation so they can go read up about it!
    /* Clearfix hack, see http://www.positioniseverything.net/easyclearing.html */
    .clearfix:after {
        content: "."; 
        display: block; 
        height: 0; 
        clear: both; 
        visibility: hidden;
    }
    /* ... snip ... */
    
  6. Be careful not to duplicate CSS or forget to remove redudant CSS. We’ve all done this, written some CSS and then removed the HTML it was styling but never removed the CSS. CSS redundancy checker to the rescue! This Ruby script will run through your CSS and find and remove redundant CSS for you.

These are just 6 guidlines I follow. Comment if you have one of your own to add…