Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Link text with CSS

I want to change my link Text with CSS, but it doesn't work.

a.testclass {
  display: none;
}

a.testclass:after {
  content: 'new text';
}
<a class="testclass;" href="someurl.com"> CHANGE THIS HERE </a>

Display none works for me but not the new text.

like image 465
Kronkorken der Bärtige Avatar asked Nov 10 '17 11:11

Kronkorken der Bärtige


2 Answers

You can hide the original text by using font-size:0; then adding the original font size back to your after:

a.testclass {
  font-size:0;
}

a.testclass:after {
  content: 'new text';
  font-size:16px;         /* original font size */
}
<a class="testclass" href="someurl.com"> CHANGE THIS HERE </a>
like image 108
Pete Avatar answered Nov 22 '22 18:11

Pete


Use font-size: 0 to hide the original text. To restore the original size use font-size: initial. You won't need to care about the original value.

a.testclass {
  font-size: 0;
}

a.testclass:after {
  content: 'new text';
  font-size: initial;
}
like image 45
ᄂ ᄀ Avatar answered Nov 22 '22 17:11

ᄂ ᄀ