Descendant Selector and Classes in CSS
Let's say we have the following code:
<div class="block">
<h2>Title</h2>
<p>
text
</p>
</div>
<div class="block">
<h2>Title</h2>
<p>
text
</p>
</div>
Let's select all headings h2 and paragraphs inside an element with class block and color them in different colors. We'll use the descendant selector (which is the space between the selectors) for this:
.block h2 {
color: red;
}
.block p {
color: green;
}
The following code is given:
<p class="eee">
text <i>italic</i>
</p>
<p class="eee">
text <i>italic</i>
</p>
<div class="eee">
text <i>italic</i>
</div>
<div class="eee">
text <i>italic</i>
</div>
Color all i tags red that are on elements with class eee.