How can I disable inherited css styles?
Cascading Style Sheet are designed for inheritance. Inheritance is intrinsic to their existence. If it wasn't built to be cascading, they would only be called "Style Sheets".
That said, if an inherited style doesn't fit your needs, you'll have to override it with another style closer to the object. Forget about the notion of "blocking inheritance".
You can also choose the more granular solution by giving styles to every individual objects, and not giving styles to the general tags like div, p, pre, etc.
For example, you can use styles that start with # for objects with a specific ID:
<style>
#dividstyle{
font-family:MS Trebuchet;
}
</style>
<div id="dividstyle">Hello world</div>
You can define classes for objects:
<style>
.divclassstyle{
font-family: Calibri;
}
</style>
<div class="divclassstyle">Hello world</div>
Hope it helps.
The simple answer is to change
div.rounded div div div {
padding: 10px;
}
to
div.rounded div div div {
background-image: none;
padding: 10px;
}
The reason is because when you make a rule for div.rounded div div
it means every div
element nested inside a div
inside a div
with a class of rounded
, regardless of nesting.
If you want to only target a div that's the direct descendent, you can use the syntax div.rounded div > div
(though this is only supported by more recent browsers).
Incidentally, you can usually simplify this method to use only two div
s (one each for either top and bottom or left and right), by using a technique called Sliding Doors.
The cleanest solution is probably to specify your divs as exact children.
Try changing this:
div.rounded div div {
background: url('bl.gif') no-repeat bottom left;
}
To this:
div.rounded > div > div {
background: url('bl.gif') no-repeat bottom left;
}