css3 - How do we select first occurence of an element in the entire document using CSS -


this question stumped me

say suppose have structure this

<!-- elements can dynamic --> <div>   <section>    </section>   <section>     <p>1st para</p>   </section>   <section>     <p>2nd para</p>   </section>   <section>    </section> </div> 

now in case how select 1st instance of p element?

note: sections can dynamic so

div section:nth-of-type(2) p {    /* won't work */ } 

this not possible using css alone. mentioned elements dynamically generated, if case programmatically put class on first <p> , target way.

by doing ensure cross-browser compatibility; since if were possible, have use css3 pseudo-classes.


Comments

Post a Comment