can’t style element separately from the list
I have a ul:
the color of the text is applied through styles:
I want the class
theSelected to have a different color, but this has no effect on the style:
Any idea why?
It’s because the selector
.myListClass li a is more specific than
One option would be to increase the specificity of
.theSelected to something like:
You could also decrease the specificity of the previous selector too.
For what it’s worth, here is the specificity calculation of each selector:
.myListClass li a- 12
.myListClass li a.theSelected- 22
Here is a helpful link for automatically calculating these values.