Yes, it's possible. Use :first-child
:
.col:first-child h2 {
padding-top: 0px;
}
The
:first-child
CSS pseudo-class represents any element that is the first child element of its parent.
Question
Is it possible to target the first .col
/h2
and add a CSS style of padding-top:0px
?
<div class="container">
<div class="holder">
<article class="col"><h2><a href="xxx">xxxx</a></h4></article>
<article class="col"><h2><a href="xxx">xxxx</a></h4></article>
<article class="col"><h2><a href="xxx">xxxx</a></h4></article>
<article class="col"><h2><a href="xxx">xxxx</a></h4></article>
</div>
</div>
Solution 2
Yes, it's possible. Use :first-child
:
.col:first-child h2 {
padding-top: 0px;
}
The
:first-child
CSS pseudo-class represents any element that is the first child element of its parent.
OTHER TIPS
You can use the pseudo-class :first-child
to accomplish that.
.container .holder article:first-child {
padding-top: 0px;
}
Also, just a heads up, you are closing your <h2>
tag with an </h4>
.