Home >Web Front-end >CSS Tutorial >How Can I Hide Text Within an HTML Element Without Hiding the Element or its Child Elements?
Hiding Text Node in Element without Affecting Children
Problem:
Hide the "Click to close" text within a specific HTML element (#closelink) without concealing the element or its hyperlink.
Solution:
Yes, this can be achieved using CSS:
visibility: collapse; /<em> Hide element </em>/<br>}</p><h1>closelink a {</h1><p>visibility: visible; /<em> Unhide child element </em>/<br>}
<a href="">Close</a> Click to close<br></div>
This method utilizes the visibility attribute. By setting visibility: collapse on the parent element (#closelink), we effectively hide it. However, by overriding this attribute with visibility: visible on the child element (the link a), we ensure that the child remains visible.
Therefore, the "Click to close" text will be hidden while the link and element remain visible, fulfilling the requirement specified in the question.
The above is the detailed content of How Can I Hide Text Within an HTML Element Without Hiding the Element or its Child Elements?. For more information, please follow other related articles on the PHP Chinese website!