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.

BoltClock
728k165 gold badges1.4k silver badges1.4k bronze badges
asked Dec 19, 2013 at 5:29

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

answered Dec 19, 2013 at 5:52

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.