Trying to figure out how to style the final paragraph following a heading using CSS.
I attempted using #div h1 ~ p:last-child
, but it ended up skipping past the second heading and affecting the last paragraph before the list. I've been diligently searching for solutions, browsing through advanced CSS guides online, only to find that they all seem to cover the same basic concepts repeatedly.
Here's the HTML snippet:
<h1>Heading</h1>
<p>content</p>
<p>content</p>
<p>content</p>
<h2>Heading</h2>
<p>content</p>
<ul>
<li>list</li>
<li>list</li>
</ul>
This is the corresponding CSS code:
#contentContainer > h1 ~ p:last-of-type {
border-bottom: 1px solid #000;
}