Using CSS, I'm trying to target all
ul
#include
#exclude
<div id="include">
<ul><li>Include List</li></ul>
<div id="exclude">
<ul><li>Exclude List</li></ul>
</div>
</div>
:not
#include :not(#exclude) ul {
color: blue !important;
}
ul
:not
You need to use the >
operator. This gets the immediate children of the element preceding. This will then get the ul
immediately descending from #include
. Updated:
Updated code:
#include > ul {
color: blue !important;
}
You would not be able to to implicitly set styles by inheritance. They don't exclude ancestors because they don't trickle down. You will need to add new rules for other elements like so:
#include ul {
color: blue;
}
#exclude ul {
color: black;
}
Fiddle: Here