Open In App

How to hide an Element using CSS ?

Hiding an element in CSS is a common task, and there are various methods to achieve it. The primary approaches involve manipulating the display property or using the visibility property.

Using display: none;

To hide an element using CSS, you can use the “display: none;” property. This effectively removes the element from the layout, making it invisible and taking up no space on the page.

Syntax:

/* Hide an element by setting its display property to none */
.hidden-element {
display: none;
}

Using visibility: hidden;

To hide an element using CSS with “visibility: hidden;”, the element remains in the layout but becomes invisible. It still occupies space on the page, unlike “display: none;”, which completely removes it from the layout.

Syntax:

/* Hide an element by setting its visibility property to hidden */
.hidden-element {
visibility: hidden;
}

Features:

Article Tags :