Nesting Selector
It is possible to apply a style for a selector within a selector.
In the example on the right, one style is specified for all p elements, and a separate style is specified for p elements nested within the "marked " class:
|
|
<html>
<head>
<style type="text/css">
p {
color:blue;
text-align:center;
}
.marked {
background-color:blue;
}
.marked p {
color:white;
}
</style>
</head>
<body bgcolor="#EDF3FE">
<p>This is a blue, center-aligned
paragraph.
</p>
<div class="marked">
<p>This p element should not be blue.</p>
</div>
<p>p elements inside a "marked" classed
element keeps the alignment style, but
has a different text color.
</p>
</body>
</html>
|
|