Home >Web Front-end >CSS Tutorial >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!