Skip to content

[HTML] Hide the text in the block

Today I want to record how to hide the text in the html block. The reason why I want to make this function is because I want to write a copy text function, but the text part is not intended to be displayed on the screen.

To achieve such a function, it is actually easy, just set display: none in style


Hide blocks in HTML

First, I will write a simple HTML file:

<p>1</p>
<p>2</p>
<p>3</p>



Output:


Then, if we want to hide the block displayed by "2", then we can modify the program to:

<p>1</p>
<p style="display: none">2</p>
<p>3</p>



Output:

We can see that although the "2" block still has our code, it is successfully hidden on the displayed page.

Tags:

Leave a Reply