1

My question is how can I select this element in CSS by edit ?

element :

<a href="***" class="example1 example2 example3" edit>click</a>
Nima
  • 118
  • 9

1 Answers1

5

You can use an attribute selector by adding square brackets [].

Attribute selectors can target:

  • The name of the attribute: a[edit]
  • The value of the attribute if it has one: a[href=***]

But since 'edit' is not a valid attribute for an <a>-Element, it's advisable to add an data- prefix in the html-code.

a[data-edit]{
  background:red;
}
<a href="***" data-edit>edit</a>
Raqha
  • 754
  • 4
  • 17