Best Practices When Writing CSS?

Discussion in 'CSS' started by ramkissoon, Sep 1, 2011.

  1. #1
    I am currently designing a site to publish online, a theme i mean, but I find my css code to be very clunky and hard to understand, but I haven't ever really released a CSS code before, and I have seen others and they look much better, as well as they have additional code for other browsers and such. Can anyone give me any tips? Thanks alot in advance.
     
    ramkissoon, Sep 1, 2011 IP
  2. ethikz

    ethikz Peon

    Messages:
    92
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Separate it in sections with correct comments etc. Make sure to name your classes and ids appropriately so anyone can read and know what it goes to. I write my code either 1 of the 2 ways shown below

    /* Header */
    .divname { background:#fff url('images/whatever.jpg') no-repeat; color:#000; }
    /* End Header */
    Code (markup):
    OR

    /* Header */
    .divname {
    background: #fff url('images/whatever.jpg') no-repeat;
    color: #fff;
    }
    /* End Header */
    Code (markup):

    Either way those are fine
     
    ethikz, Sep 1, 2011 IP
    ramkissoon likes this.
  3. babushkyn

    babushkyn Member

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    2
    Trophy Points:
    26
    #3
    Show us a piece of your code, so we can tell if it's really as messy as you say :)
     
    babushkyn, Sep 2, 2011 IP