DivitoDesign

Everything for the Web Professional

I’ve Optimized My CSS Writing Style

Information about the Author:

Name:

URL: http://twitter.com/divitodesign

Description enjoy design, write articles, like typography, love football, keep chilling.

More on: CSS

9 Comments

  1. G’day there!

    I actually switched the other way around a while back … I was using the one-line-method but in most of my sites these classes tend to get very big and that is difficult to debug as well.

    I think the best way would be a compromise between the two:

    p {padding: 20px; color: #666;} /* Simple line */
    div#menu {
    position: absolute;
    left: 10px;
    top: 100px;
    width: 490px;
    height: 20px;
    padding: 5px;
    border: 1px solid #aaa;} /* Bigger line */

  2. I usually don’t stick to this method in development because it’s lot more of a pain to edit than having it spread out. If you order your css like html, top items at the top, then work your way down to the bottom it’s still easy enough to work with… then you can make it fancy when it goes live.

  3. Kip says:

    I do write my code the old way. But once I get the CSS debugged and looking right in all the enviroments I reformat it to a slightly more tighter formatting system using less lines but for time editing sake if there is a change to be made I keep an original copy of the style sheet.

  4. Thanks for the comments guys. Seems like a lot of you use the old method. :)

    @Ruud – That problem occurred to me as well, but that can be solved with your tab button. If you ‘tab’ between each element your class will become a bit bigger, but it will be organized. And you have less scrolling to do.

    @Chris – Like I told Ruud here above, you could add some tabs between the elements. It stays organized and in my opinion it is easier to edit and debug as well. It definitely speeded that process up.

    @Kip – That’s smart, but you should always keep your backup copy ready if something goes wrong. What CSS optimizer do you use?

  5. hi there!
    I don’t agree with you in this case. I rather write my css in multiple lines than just in one. You may be have to scroll more, but it’s much easier to navigate and to see all the properties.

  6. @Thiemo – In my opinion and experience it is almost the same in the ability to navigate. Both works good, but in this way you have less scrolling to do:). Thanks for your comment.

  7. I think the “old” way is much more comfortable to work with.

  8. I think the old style better, more clear

  9. Sumesh says:

    I began writing CSS in the single-line form, then switched to the old form when I saw the beauty of it, and am back in the new style once I realized the optimization benefits.

    Now that I use single-line CSS, I don’t find the need of using a compressor – there is very little that can be saved.

Please Respond and Give your Opinion

We use Gravatar to handle our avatars. Get one there!