-1

I need to style a specific word with CSS, but I'm not sure how I would be able to do this. For some reason I can't assign any ID's or Classes to the elements of a list, this is the example:

<ul class="xxx"> <li><a href="#" class="xxx"><span class="yyy">White</span></a></li> <li><a href="#" class="xxx"><span class="yyy">Black</span></a></li> <li><a href="#" class="xxx"><span class="yyy">Blue</span></a></li> </ul>

For example, the word white with color: white; I cannot use nth-child because in a page on my website the order of the li can be different.

I was wondering if there is a way with CSS, to tell the color only of the li (or span) which contains white.

Is there anyone who knows how I could do this? Thank you!

Gerwin
  • 1,572
  • 5
  • 23
  • 51
Nicola
  • 1
  • 1

1 Answers1

1

You should assign a class on them:

<ul class="xxx"> 
   <li><a href="#" class="xxx"><span class="yyy white">White</span></a></li> 
   <li><a href="#" class="xxx"><span class="yyy black">Black</span></a></li> 
   <li><a href="#" class="xxx"><span class="yyy blue">Blue</span></a></li> 
</ul>

And then apply the color:

.white{
    color: white;
}
.black{
    color: black;
}
.blue{
    color: blue;
}
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231