CSS Selector, find first appearance in an nested content -


i tried different things first element set display property block, rest should set none. i'm not able first appearance of element, every time use selector elements or none of them. maybe of know css tricks solve prob.

here code:

<div class="some_class"> <p>...</p> <p>...</p>  <p> <object height="300" width="480"></object></p>  <p> <object height="300" width="480"></object></p>  <p> <object height="300" width="480"></object></p>  <p>...</p></div> 

i need first appearance of "object". can't change html , have find way problem solved using nice css selector. idea?

i tried code like: .some_class p > object:first-of-type way every "object" gets selected... because every "object" first of type of parent "p".

note: work when elements static, can change nth-of-type() p, if elements dynamic, need go javascript

try this

.some_class p:nth-of-type(1) object {    /* styles goes here */ } 

this select objects in p element, use if have single object element in p, if you've multiple use this

.some_class p:nth-of-type(1) object:nth-of-type(1) {    /* styles goes here */ } 

Comments