Is there a way to apply a specific style exclusively to the very first element within a container, only if it is an h1, h2, or h3? However, if there are multiple headings of different levels on the same page, only the initial one should receive the designated styling.
For example:
<div class="container">
<h2>I want to modify this</h2>
<p>....</p>
<h3>But not this!</h3>
<h2>and not this!</h2>
</div>
I attempted using the following code:
.container h1:first-of-type, .container h2:first-of-type, .container h3:first-of-type {
padding-top: 0 !important;
}
The issue arises when both the first H2 and H3 are impacted by this code.
I also tried the following, but unfortunately, it did not work:
.container > h1:first-of-type, .container > h2:first-of-type, .container > h3:first-of-type {
padding-top: 0 !important;
}
Any suggestions on how I can accomplish this?