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?
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.
Give your div an id (id="myDiv"), then add this code to your stylesheet:
#myDiv {
Style information
}
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
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.
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.