How can I select particular href tag using attributes

Viewed 47

I want to create the selector using a tag href attributes. I try the below one but not working well. Please check the below code

HTML <a href="https://google.com/">Google</a> <a href="https://codepen.io/pen/">Codepen</a>

CSS ahref="https://google.com/" { background-color: #f00; color: #fff; padding: 10px; }

2 Answers

you can also use class it's help you to reuse a code.

html

   <a href="https://google.com/" class="selected">Google</a>
   <a href="https://codepen.io/pen/">Codepen</a>
   <a href="https://gmail.com" class="selected">Gmail</a>

css

.selected {
  background-color: #f00;
  color: #fff;
  padding: 10px;
}

here is sample work https://codepen.io/imnoorfahad/pen/yLppaLa

Related