0

I have a two <a> tags and it's HTML as below:

<ul>
  <li><a href="#">This is my link</a></li>
  <li><a href="#">This is my link</a></li>
</ul>

What I want is, to replace links text as this:

<ul>
  <li><a href="#">custom 1</a></li>
  <li><a href="#">custom 2</a></li>
</ul>

This is how I tried it using CSS. But still I couldn't figure this out.

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul li {
  padding: 0;
  margin: 0;
}

ul li a {
  color: #fff;
  font-size: 0;
  position: relative;
}

ul li a:first-child:after {
  content: 'Custom 1';
  position: absolute;
  top: 0;
  left: 0;
}

ul li a:last-child:after {
  content: 'Custom 2';
  position: absolute;
  top: 0;
  left: 0;
}

Hope somebody may help me out. Thank you.

user3733831
  • 2,886
  • 9
  • 36
  • 68

2 Answers2

0

ul li:first-child a:before {
  content: 'Custom 1';
  position: absolute;
  color: DodgerBlue;
  background: #fff;
  width: 100px;
  text-decoration: underline;
}

ul li:last-child a:before {
  content: 'Custom 2';
  position: absolute;
  color: DodgerBlue;
  background: #fff;
  width: 100px;
  text-decoration: underline;
}
<ul>
  <li><a href="#">This is my link</a></li>
  <li><a href="#">This is my link</a></li>
</ul>
Vaibhav
  • 1,412
  • 1
  • 10
  • 14
-1

If you want to make it dynamicly, you should use a Script.. With this snnipet : document.getElementById("ahref1").innerHTML = "Google";