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>
Was it helpful?

Solution 2

Yes, it's possible. Use :first-child:

.col:first-child h2 {
    padding-top: 0px;
}

:first-child

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>.

DEMO

pseudo-class :first-child

.col h2:first-child {
    padding-top: 0;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top