FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

CSS n00b's troubles

 


gtherockgod
Hey y'all, i'm still new to this whole CSS thing.

How do I constrain the effects of a <style>...</style> to one particular div for I can have a different effect in another div?
Cal_123
You could use an external stylesheet. When you need to change the content of the element, just use the <style> function in the main code. That will overwrite whatever is put in the external stylesheet.

That's how I do it, but there may be ways that are alot more simple.
Stubru Freak
Give your div an id (id="myDiv"), then add this code to your stylesheet:

#myDiv {
Style information
}
jabapyth
on if you want it to effect a set of divs, put class="special" in the divs' tags, and
Code:
div.special {
// css here
}
in your stylesheet
rein
i agree with stubrufreak. Give your div an id and that way everything will become specificaly addressable:

Code:
myDiv p{
color: red;
}
myotherDiv p{
color: blue;
}


Go here for an overview of what's possible.
KHO
I agree with Stubru Freak, but also there are some things you may be doing that forbid the # symbol as it can be used maliciously I guess. In these rare instances, you can use this code:

<style>
div.stylename {
//css
}
</style>
<div class=stylename>

Otherwise I would lean towards using the id attribute if applicable. Theoretically they can function the same, but with class freed up you can use it for something more useful.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.