1
.class + p:first-child{

}

the above code not working, unless it's element instead of class, like p:first-child.

<div class="wrap">
<h3></h3>
<div style="clear:both"></div>
<p></p>
<p></p>
<p></p>
<p></p>

how do I select first p base on the class wrap? I do not want to apply class name on p.

1 Answer 1

1

You can't use :first-child here, because in this case first-child of class:wrap is <h3> .In your desired case try this

.wrap > p:nth-of-type(1) {
    color:red

}

Fiddle is HERE

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.