Get the App
SLTechnology News&Howtos  ›  Development  › 

How to make elements invisible by html

Shulou Source: shulou.com Published: 2022-06-03 07:09:59 09月20日 Update

Editor to share with you how html sets the elements invisible. I hope you will get something after reading this article. Let's discuss it together.

Html sets the element invisible method: 1, add the hidden attribute in the element tag; 2, use the style attribute to set the "display:none" style in the element tag; 3, use the style attribute to set the "visibility:hidden" style in the element tag.

The operating environment of this tutorial: windows7 system, HTML5 version, Dell G3 computer.

There are three ways to make elements invisible in html:

Use the hidden property

Use the style property to set display:none

Use the style property to set visibility:false

Obviously, there are two ways to make elements invisible:

The element is completely invisible, the element will not occupy space, as if it had disappeared

The element is invisible, but it still occupies the original space, as if invisible

Use the hidden property

Hello

The effect of using the hidden attribute is to automatically change the element's display attribute to none when you render the DOM. Note that the only use of the hidden attribute is here: change display to none only the first time you add the hidden attribute. In the future, even if the display attribute becomes the block,hidden attribute, it will still be there.

It can be seen that hidden and display=none have the same effect. But not as direct and fundamental as display. Therefore, instead of using the hidden property in the future, access the display property in the style directly.

Use the style property to set display:none

Display=none in style can make an element disappear completely, without a trace, without taking up space.

Hello

Use the style property to set visibility=hidden

In the case of visibility=hidden in style, the element seems to be invisible, but still occupies the original space.

Hello has finished reading this article, I believe you have some understanding of "how to set elements invisible in html". If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

Tags: Attributes elements spaces labels effects methods styles articles the same without a trace we can see that is tutorials ways more fundamental environment purpose and so on. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Xiaomi Shulou Tech Info Redmi