Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple classes 1

Status
Not open for further replies.

crystalized

Programmer
Jul 10, 2000
390
0
0
CA
Is it possible to use multiple classes for 1 div?

for example:

.regSize{
font-size: 12pt;
}
.regColour{
color: #7575AA;
}

in the div
<Div ID=&quot;someDiv&quot; class=&quot;regSize,regColour&quot;></div>

Of course I am just speculating on the div part since I do not know if it is possible at all and if it is what the syntax is.

Thanks in advance for the help. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Hi,

You can nest DIV tags, try something like this:

<div id=&quot;outerDiv&quot; class=&quot;regSize&quot;><Div ID=&quot;someDiv&quot; class=&quot;regColour&quot;>hello</div></div>

HTH, [sig]<p>Russ<br><a href=mailto:bobbitts@hotmail.com>bobbitts@hotmail.com</a><br><a href= is in</a><br>[/sig]
 
Thanks Russ that is a good idea I will give it a try. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Aha... could this just maybe be an example of Inheritance? ;-) [sig][/sig]
 
Rycamor

Could you elaborate on what you mean by inheritance. I can see that the inner div would inherit the properties that it did not specifically set itself from the outer div. But if you are talking about something else about how to implement inheritance I would be quite interested. Is there some way to have classes inherit from other classes without nesting the div tags?

I am trying to work my way through the CSS2 specification and am curious if there is some section I should look to for more information on inheritance. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
It's actually not a really good (programmatic) example of inheritance, but it shows an aspect of modern HTML/DHTML and how it relates to Javascript.

I don't know exactly where to look in the formal CSS2 spec, but the whole idea of the modern Document Object Model (DOM) is that it's object-oriented (OO). This means, among other things, that objects belonging to one class can pass those properties to the objects under them in heirarchy.

In true OO programming, classes can inherit properties and methods from other classes. I'm not sure if plain CSS2 can work in that way, but I will check it out.

The real point is that Javascript can take advantage of this, and the programmer can create custom objects that have self-defined properties and methods, but can also interface with the pre-defined objects and properties in the DOM. This give incredible flexibility. Netscape 4.x doesn't quite have this full level of flexibility, but IE 4+ and Netscape 6+ (coming) do have it.

An excellent book to read is &quot;Javascript Objects&quot;, by Wrox Press. [sig][/sig]
 
U can use the DIV's ID:
E.g.
the html:
<DIV ID=&quot;thediv&quot; class=&quot;foo&quot;>

/*now in the css:*/

.foo{color:#ffffff;}

/*has the same effect with:*/

#thediv{color:#ffffff;}

Don't know why u wanna use this for but hope this helps.

Manos Batsis
manosb@profile.gr [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top