Hiding Text without HTML Tags in HTML
A user encounters a challenge where a particular section of text within an HTML document is not enclosed by any HTML tags. The goal is to hide this text without wrapping it in a div or other HTML element.
CSS Solution
The recommended approach involves a CSS hack that utilizes font-size:
.entry { font-size: 0; } .entry * { font-size: initial; }
When applied to the given HTML code, this CSS effectively hides the desired text while preserving the visibility of the other elements:
<div class="entry"> <p class="page-header">
By setting the font size of the ".entry" class to 0, all its child elements are hidden. The second rule then selectively sets the font size back to its initial value, restoring the visibility of the desired elements within the ".entry" container.
The above is the detailed content of How Can I Hide Un-tagged Text in HTML Using Only CSS?. For more information, please follow other related articles on the PHP Chinese website!