Reputation: 13
I want to set all paragraphs to color green regardless of what element the parent is and also regardless of the number of parents and sub-parents, as long as they are inside the class "main_class".
<style>
.main_class > (?) > p { color: green; }
</style>
<div class="main_class">
<p> Test </p>
<div>
<p> Test </p>
</div>
<td> Test </p>
<div>
<div>
<td>
<p> Test </p>
</td>
</div<
</div>
</div>
Upvotes: 1
Views: 65
Reputation: 611
It is simply to add css as following:-
.main_class p {color: green;}
Upvotes: 2
Reputation: 157334
The selector you are using will only select the p
which are directly nested under .main_class
so use the following selector. This will select any p
element at any nested level as long as it's nested under .main_class
.main_class p {
color: green;
}
Would also like to add here that your Markup is invalid. You are mixing up the
td
,div
&p
. For more info, refer to W3C HTML Validator to validate your markup.
Upvotes: 2