Sean wrote:

Does anyone know if there is a common way of listing styles in CSS? I don't mean the order of a:hover a: visited, or the order of specification. I am thinking more of some logical order that would be helpful to anyone else working on stylesheets I have created.

Are you meaning in a micro or macro sense. i.e. how to structure sets of statement within a stylesheet or how to structure a set of declarations within a statement?


If it's the former there tend to be a couple of main ways. One is to group statements into logical types, such as all layout goes in one place, all text stuff in another. However I personally break this info into separate stylesheets as I find it easier to manage.

Another popular way is to structure stylesheets based on selector type, so you may have all element selectors first, then all id's and lastly all classes. I can see the logic behind this but it's not something I favour.

The way I tend to arrange statements is by position in the flow of the document. So I'll have all universal statements at the top, then statements relating to the header, nav, content and finally footer statements at the bottom. This works well for me, but I do often find that I'll need to add a new statement later that's the same of similar to one I already have. Rather than taking the original statement out and putting it up top with the universal statements, I tend just to tack a new selector on. This means that sometimes statements aren't always exactly matching the flow of the document. This is fine if you've only got one person working on the CSS, but would get confusing if you've got multiple people using the same file.

As for arranging declarations within a statement, because statements don't tend to be so long, I generally don't have a format. I simply put them in the order I write them in.

Andy Budd

http://www.message.uk.com/

******************************************************
The discussion list for  http://webstandardsgroup.org/

Proud presenters of Web Essentials 04 http://we04.com/
Web standards, accessibility, inspiration, knowledge
To be held in Sydney, September 30 and October 1, 2004

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************



Reply via email to