HighDots Forums  

Classes with the same name?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Classes with the same name? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Erik Funkenbusch
 
Posts: n/a

Default Re: Classes with the same name? - 09-23-2003 , 01:23 PM






On Tue, 23 Sep 2003 18:14:29 +0100, Barry Pearson wrote:

Quote:
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!)
The way I now look at it is this, and of course this may be wrong as well:

"classes" are "types". When one says that a particular element, say <p>
has a class="content" then you are saying that this <p> is a "content". It
might also be class="content left tuesday 2001" in which case it also "is
a" all those other types as well, much like multiple inheritance.

This is fairly straight forward, and these rules are also straight forward,
though I must admit to not knowing which "class" takes precedence (earlier
or later in the list) when there is a conflict.

One can look at ID's as object names that also infer a type (class). For
style purposes they are the same as classes, other than only allowing a
single instance of that type (DHTML offers other ways to use ID's, but
we'll not get into that here).

Now, it's all well and good to say that a <p> is-a "content", but how are
types defined? HTML doesn't care, it just assigns them the type and allows
the browser to figure out it's definition and apply it.

CSS is the mechanism in which the browser looks up type (class)
definitions. It's something like IDL or other meta-languages in which you
define the objects in a different language/format than it is interpreted.

In fact, it might be best to think of a browser as not an HTML renderer,
but a CSS renderer, that uses HTML as its transport format. It's not
difficult to imagine using CSS with other kinds of languages, such as SGML,
XML, or even non-SGML based languages like TeX or RTF.

Since "cascade" could be another word for "inherit", one could think of CSS
"selectors" as "class overloading".


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.