See an option with CSS, but I make it clear that it is not very semantic, because even with 0 font a screen reader can have access to this text...
The technique consists of "delete" the text inside the link by placing the size of the font
as 0, but you use a pseudo-element ::after
on the link and using the property content:""
; you put the new text.
Note that only the element that the attribute href = /rota/rota1
will receive the new text
[href="/rota/rota1"] {
font-size: 0;
color:red; /* cor de texto que o filho ::after vai herdar */
}
[href="/rota/rota1"]::after {
content: " MEU TEXTO NOVO";
font-size: 16px !important;
}
<td class="corpo-nome">
<a href="/rota/rota1">
guilherme
</a>
</td>
<td class="corpo-nome">
<a href="/rota/rota2">
João
</a>
</td>
If you want only the link inside the <td>
classy .corpo-nome
has the text changed just put the css this way
.corpo-nome a{
font-size: 0;
color:red;
}
.corpo-nome a::after {
content: " MEU TEXTO NOVO";
font-size: 16px !important;
}
<table>
<tr>
<td class="corpo-nome">
<a href="/rota/rota1">
guilherme
</a>
</td>
</tr>
</table>
Keep in mind that: the user may not even see the text we hide with font-size: 0, but the Google Bot will definitely read this content... Will solve so you see with your eyes, but for the crawlers and screen readers the text will remain accessible...
It would not be the case to use a $("a[href='<your link>']"). text('your text');?
– Felipe Avelar
You want to take the name
guilherme
that is there and then put another name in place only with CSS is it? Or you want to change the value of href of the link?– hugocsl
I have several links on the same page, didn’t work no :/
– Gustavo
With css? would be with js, right? I need to change the same name. What is the link description.
– Gustavo
Gustavo da para fazer com CSS tb, but the most indicated for semantic and accessibility issues would be with JS even, but only to remove the name completely, because only with CSS you can "hide" the name and put gold. You can’t really delete the screen name only with CSS, with CSS you can hide it and show only the new name. If you’re interested I can make an example for you
– hugocsl
Yes, I have interest! please rsrs
– Gustavo
@Gustavo could explain his doubt better, that maybe we understood something else...
– Felipe Avelar
I edited there @Felipeavelar
– Gustavo