Home > Web Front-end > CSS Tutorial > How Can I Hide Unmarked Text in HTML Without Modifying the HTML Code?

How Can I Hide Unmarked Text in HTML Without Modifying the HTML Code?

DDD
Release: 2024-12-28 06:02:17
Original
854 people have browsed it

How Can I Hide Unmarked Text in HTML Without Modifying the HTML Code?

Concealing Unmarked Text Within HTML Code

Problem:

An HTML code contains text that lacks HTML tags. Specifically, there is a "Enter" text following a

tag that needs to be hidden. Modifying the code by wrapping it with an HTML tag is prohibited.

Solution:

A CSS hack utilizing font-size can be implemented:

.entry {
  font-size:0;
}
.entry * {
  font-size:initial;
}
Copy after login

HTML:

<div class="entry">
  <p class="page-header">
Copy after login

In this method, the .entry class has a font-size of 0, which effectively hides the text within it. However, any nested elements within .entry (e.g., *) have their inherited font-size reset to its initial value, making text within those elements visible again.

This CSS hack effectively conceals the "Enter" text without the need for HTML tags.

The above is the detailed content of How Can I Hide Unmarked Text in HTML Without Modifying the HTML Code?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template