The CSS property used to control the visibility or hidden state of an element is
visibility. The visibility property can be set to one of three values:
visible : This is the default value. It means that the element is visible and will take up space on the page.
hidden : This means that the element is not visible, but it will still take up space on the page.
collapse : This is a newer property that means that the element is not visible and it will not take up space on the page.
For example, the following CSS code will hide the div element:
Code snippet
div {
visibility: hidden;
}
The visibility property can be used to create a variety of effects, such as:
Hiding elements that are not yet ready to be seen : For example, you might want to hide a navigation bar until the user scrolls down the page.
Showing and hiding elements based on user input : For example, you might want to show a message box when the user clicks on a button.
Creating a loading animation : For example, you might want to show a spinner while the page is loading.
The visibility property is a powerful tool for controlling the visibility of elements on your web pages. By using it correctly, you can create a variety of effects that will make your pages look great and be easy to use.
Here are some additional tips for using the visibility property:
Use the visibility property sparingly. Hiding elements can make your pages harder to use.
Use the visibility property to create a clear hierarchy on your pages. Make sure that the most important elements are always visible.
Use the visibility property to create a sense of movement and animation on your pages.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
The CSS property used to control the visibility or hidden state of an element is visibility. The visibility property can be set to one of three values:
For example, the following CSS code will hide the
divelement:Code snippet
The visibility property can be used to create a variety of effects, such as:
The visibility property is a powerful tool for controlling the visibility of elements on your web pages. By using it correctly, you can create a variety of effects that will make your pages look great and be easy to use.
Here are some additional tips for using the visibility property: