Skip to content


Structure CSS Files

Sometimes we forget that CSS is actually code. Usually it is just thrown together as an after thought because we simply one a few styles here and there. However, anyone who has dealt with CSS files over 100 lines long knows that just throwing together tags in a wild maylay is not the way to go.

CSS code should be laid out and structure just like any other code we write. Emil at Friendly Bit has a detail article on how to structure large CSS files. He mentions five (5) main methodologies:

  1. Order your selectors like the HTML
  2. Always use the “full path” to elements
  3. Indent your code cleverly
  4. Each declaration on its own line
  5. … in alphabetic order

Posted in CSS.

Related Posts

  • None Found

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Emil Stenström says

    Hi, that’s great point many people are missing: we should treat CSS like real code, not some ugly hack. Thanks for mentioning my article!



Some HTML is OK

or, reply to this post via trackback.

CommentLuv Enabled