CSS: Keep HTML tags and hide only text content inside <a> tags
P粉973899567
P粉973899567 2024-03-28 21:52:12
0
1
433

There is an "a" with an "img" inside it, followed by the text of the link. I need to hide these link text without hiding the "img" tag.

<a href="https://www.example.com/page">
    <img src="images/example.jpg" width="50" />
    This is a link
</a>

In this "a" tag, I need to hide the "This is a link" part and leave only the "img" tag to display. The HTML content cannot be changed (new HTML tags added or removed). How can I do this?

P粉973899567
P粉973899567

reply all(1)
P粉846294303

Without knowing the rest of html or the use case, maybe you can just set the size of the a tag and font-size attribute to zero That’s it.

a {
  font-size: 0;
  width: 0;
  height: 0;
}

  
    This is a link
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template