Thanks Patrick and others.
For the record I think that the Malarkey URL you refer to is:
http://www.stuffandnonsense.co.uk/archives/stylesheet_ordering.html
It has given me lots of things to think about.
Regards,
Charlie
Patrick Lauke wrote:
C Slack
Having sorted out the html code to make it more readable and
modifiable
it seems that we have shifted the mess to style sheets. Many of the
sheets I look at are long, comment-less and very difficult to
understand.
So that I don't fall into the same trap, can anyone recommend some
reading on how to make style sheet structure and layout both
understandable and also easily modified?
In general, it's a good idea to stick to some form of style guide
(essential when more than one person is working on styles, or if
it's likely that somebody else will inherit responsibility of those
styles in future).
In general, I try to stick to simple things such as:
- sensible indenting
one liners for really short and sweet ones
selector { rule; }
proper formatted block for more convoluted ones
selector { rule;
rule;
rule;
rule;
}
- striving to use the same order in which rules appear
selector { font: ...; color: ...; margin: ...; padding: ...; etc }
- use comments whenever something obscure / counterintuitive happens
(particularly if it's a hack)
- order your css into sections (general, header, navigation, etc)
as they appear in your XHTML; there is another school of thought
that prefers to order the css alphabetically by selector. personally, i
find this more counterintuitive (as you often fail to see the inheritance
and cascade clearly), but if it works for you, that's another way to
go about it
- use descriptive, but not overly wordy IDs and classnames
- split up your stylesheet into separate stylesheets when appropriate
- optimise, optimise, optimise: take advantage of inheritance and cascade
- related to the previous: avoid classitis and IDitis (or whatever
we want to call it); know your cascade and inheritance, and don't stick
a class or ID on every single element of your document
I seem to remember Malarkey http://www.stuffandnonsense.co.uk had an
article about this sort of thing a few months back...but the URL escapes me...
Patrick
Patrick H. Lauke
Webmaster / University of Salford
http://www.salford.ac.uk
**
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list getting help
**
--
Charles Slack,
15, Higher Greenfield,
Preston,
PR2 3ZX
**
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list getting help
**