I have an unordered list like this:
-
list1
- Sub list1<
Use the direct descendant operator >
for that:
.list > ul > li { ... }
The >
operator selects only elements that are direct children of the element(s) before it.
Note however, anything inside that list item will of course have the background of the list item despite not having any background color directly assigned to it.
Alternatively, you can now do:
li:not(li li) { background: #ccc; }
You can use the > operator for that, like this:
.list > ul > li{
background:#ccc;
}
The only way of doing this is like:
.List > ul > li { background-color: #ccc; }
If you want to apply only the bgcolor to the ul simply do:
.List > ul { background-color: #ccc; }
:)