Erik Funkenbusch wrote:
On Mon, 22 Sep 2003 23:24:13 -0400, Nikolaos Giannopoulos wrote:
[snip]
If this is at all your case just ignore anything you have ever heard
about classes from OOP languages when dealing with CSS classes and it
will save you a lot of headaches.
Actually, it's not as different as you might think. It just takes a
little bending of your understanding to see it :)
It is all very well to say what CSS classes are not. The hard bit as far as I
am concerned is to replace that with what they are. (I have the misfortune to
understand a fair amount about OOA & OOD as well as OOP. Aaaaaaarrrggghh!)
My current mental model is to forget about classes as anything resembling
anything else with the same name. They might as well be called "trogs". (So
far, so good). But I worry that I have got things fundamentally wrong, and
need a "paradigm shift". I've summarised my mental model below - I hope that
no-one will tell me that I need a "paradigm shift".
I now think of it instead from the point of view of a rendering engine working
serially (?) through a document such as an HTML document. What does it do at
each stage?
Initially, within the <head> </head> block, it (conceptually at least) builds
up a composite style sheet, according to the cascading rules of linked CSSs &
any styles declared there. Then it starts on the <body> </body> block, and at
each new element (tag), it has to decide "how do I render this element?"
Some elements themselves have styles, and these are, in effect, combined with
the composite style sheet for the duration of the element. (But I'll ignore
this, because I don't use them!)
Then the task of the rendering agent (or user agent) is to determine, for this
next element, what set of values from the composite style-sheet to apply for
each of the relevant properties. And the first question is "what rules are
SELECTED?" I see it as primarily about SELECTION. My assumption is that if you
can understand which rules are selected, and then understand the inheritance
and priority principles that apply where there are contradictions and
incompleteness within the selected rules, you end up with an understanding of
what the rendering agent will do.
Perhaps the biggest challenge for me is that this model prevent me from
knowing what the effect of a particular rule is in isolation. It isn't like
being able to discuss what the class of an object specifies. Even later
declarations within the same rule may overide what has just been learned.
Later rules may also do so. And then, at "browse time", all that may be
blown-away by new declarations that only become apparent when the rendering
agent reads the document!
I worry about this model because of its lack of predictability. But what is
really important is: "is this mental model useful?"
--
Barry Pearson
http://www.Barry.Pearson.name/photography/ http://www.BirdsAndAnimals.info/ http://www.ChildSupportAnalysis.co.uk/