Change the text of an HTML elment using CSS only

Let's assume that you want to hide the text of a button using only CSS:

html
<button>Click me</button>

You can set the font-size to zero:

CSS
button{
    font-size: 0px;
}

At this point you can replace the text:

CSS
button::after{
    content: 'Replaced text';
    font-size: 12px;
}

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.