CSS : target an "<a>" tag element

Viewed 111

Say you have this html syntax :

<a href="#myId" aria-controls="hotel" role="tab" data-toggle="tab" aria-expanded="true">My Hotel</a>

What would be the CSS to target this tag, if I want to select the "aria-expanded" value, and the "href" value ?

2 Answers

The CSS to target the a href and aria-expanded value would consist of the following:

a[aria-expanded="true"] {
  background-color: lightgrey;
}
<a href="#myId" aria-controls="hotel" role="tab" data-toggle="tab" aria-expanded="true">My Hotel</a>

Related