Home > front end >  How to add CSS on specific element while using pseudo-class or pseudo element
How to add CSS on specific element while using pseudo-class or pseudo element

Time:02-11

This are 5 pieces a href and when hover unto them Hello World!! would show up unto there rigth side.. How can I make Hello World!!only show on Only Here when hover? Is there like

<a style =":hover::after display: inline-block; content: "Hello World!!"; font-size: 16px; ... etc " href="#">

POC coding argument of some sort to design specific element while using pseudo-class or pseudo element

a:hover::after {
  display: inline-block;
  content: "Hello World!!";
  font-size: 16px;
  font-weight: bold;
  padding-left: 5px;
}
<a href="#">Not Here</a><br>
<a href="#">Not Here</a><br>
<a href="#">Only Here</a><br>
<a href="#">Not Here</a><br>
<a href="#">Not Here</a><br>

CodePudding user response:

Is this what you want to chieve?

a.hello:hover::after {
  display: inline-block;
  content: "Hello World!!";
  font-size: 16px;
  font-weight: bold;
  padding-left: 5px;
}
<a href="#">Not Here</a><br>
<a href="#">Not Here</a><br>
<a  href="#">Only Here</a><br>
<a href="#">Not Here</a><br>
<a href="#">Not Here</a><br>

  • Related