Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  186] [ 1]  / answers: 1 / hits: 16920  / 11 Years ago, thu, july 11, 2013, 12:00:00

I've been struggling with finding a way to only display the first child of my div and hide all the rest. Can this be done purely in css or do I have to involve some Javascript?



So, how can I get this to only display first p-tag?



<div id=test1>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
<p>Lorem ipsum</p>
</div>


http://jsfiddle.net/8XYNx/


More From » css

 Answers
111

try this



http://jsfiddle.net/8XYNx/10/



CSS



  #test1 p{
display:none;

}
#test1 p:first-child{
display:block;
}

[#77062] Wednesday, July 10, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
anikas

Total Points: 258
Total Questions: 102
Total Answers: 95

Location: Monaco
Member since Sun, Jan 16, 2022
2 Years ago
anikas questions
;