Home > Blockchain >  CSS : target an "<a>" tag element
CSS : target an "<a>" tag element

Time:12-08

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 ?

CodePudding user response:

You can use this selector

a[href="#myId"][aria-expanded="true"]

more info: https://www.w3.org/TR/CSS2/selector.html#attribute-selectors

CodePudding user response:

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>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related