Home >Web Front-end >CSS Tutorial >How Can I Hide Text Inside a Parent Element While Keeping Child Elements Visible?

How Can I Hide Text Inside a Parent Element While Keeping Child Elements Visible?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-07 19:16:14998browse

How Can I Hide Text Inside a Parent Element While Keeping Child Elements Visible?

Hiding Text within an Element: Preserve Child Visibility

To conceal specific text within an element while maintaining visibility of child elements, employ the visibility attribute. In this instance, you aim to hide the "Click to close" text without impacting the div or link within it.

The code below achieves this:

#closelink {
  visibility: collapse;
}

#closelink a {
  visibility: visible;
}

The #closelink selector hides the text within the div, making it visually disappear. However, the #closelink a selector overrides this behavior, ensuring that the link element remains visible. As a result, the link remains accessible and responsive to user clicks, while the text "Click to close" becomes invisible.

The above is the detailed content of How Can I Hide Text Inside a Parent Element While Keeping Child Elements Visible?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn