CSS target element

How can I target the second <span> in the div (Rättsmål), and make it red? I dont want massive amout of extra classes.

<div class="subjects_container"> 

		<div> <span>1</span><span>Rättsmål</span><span></span> </div>

</div>

I tried the following, but it made both “1”, and “Rättsmål” red.

.subjects_container:nth-child(2) {

		color: red;

}

I also tried, no success.

.subjects_container > div:nth-child(2) {

		color: red;

}

Hi there qrazyneo1,

try it like this…

.subjects_container span:nth-of-type(2) {
    color: #f00;
}

coothead

2 Likes

You’re the man! This works good, thanks.

 
 
        No problem, you’re very welcome. :winky:
 
 
        coothead

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.