I have two <a> in a <p> and I want to assign them different borders when selected.
When the user clicks on a <a> a JavaScript sets the class to "selected" and the border shall turn to green if it is the first <a> but if the second <a> is clicked and assigned class="selected" the border shall turn to red.
What I would like to do in CSS is something like:
a:first-child.selected {border-color:green}
a.selected {border-color:red}
But that does not work.
There are a lot of examples out there which describes how to select the first-child of a specific class but none which describes how to select the first-child of a certain tag IF it has a certain class.
Is this possible to achieve at all?
What I have done now is to set the first <a> as class="yesselected" and if the second is clicked it will have class="noselected".
But i would really like to know if it is possible to select a tag if it is the first one and it has a certain class