When attempting to color list items in an unordered list using the general sibling combinator, nothing seems to happen:
p {
color: blue
}
h1 ~ li {
color: red;
}
<h1> Title of site </h1>
<p> Text in the site </p>
<p> Second paragraphy </p>
<ul>My list
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
However, a span
inside a paragraph colors with no issues at all:
p {
color: blue
}
h1 ~ p span {
color: red;
}
<h1> Title of site </h1>
<p> Text in the site </p>
<p> Second paragraphy <span> heyo </span></p>
<ul>My list
<li>First</li>
<li>Second</li>
<li>Third</li>
</ul>
So, is the span
on equal footing with the paragraph when it comes to inheritance even though it's nested within the paragraph? Why?
A comprehensive source for learning about inheritance seems hard to come by.
Also, just as a side note... how can I style the title of an unordered list without affecting the list items? Is assigning an identifier to the ul
necessary?
Styling the ul
would result in the list items inheriting that styling as well.