I have the following html snippet
<body>
<p>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</span><br />
</p><p>
<span>morbi id vestibulum lectus. maecenas facilisis orci vitae</span><br />
<span>urna pulvinar cursus. etiam id laoreet metus. cras vitae</span><br />
<span>elit ipsum. donec a sagittis nisi. sed nec nisi nibh,</span><br />
<span>fringilla fermentum quam. vestibulum lorem felis, gravida</span><br />
<span>et faucibus ac, ultrices nec lectus.</span>
</p>
</body>
My css is the following
span:nth-of-type(3n+1) {
color:red
}
span:nth-of-type(3n+2) {
color:green
}
span:nth-of-type(3n+3) {
color:blue
}
I would like the second span ("morbi id...) to be colored in green and all the rest of span elements to follow reg-green-blue sequence. However, since span is inside the p element, it is colored in red, as nth-of-type takes into account order in relation to parent element. How can I accomplish this in css?
spantags, as they are not sibilings.... There are no such thing as "cousin" selector on css...