To hide a div
element in CSS, you can use the display
property and set its value to none
. This action will make the div
invisible and remove it from the document flow, ensuring it doesn't take up any space in the layout.
Here's the method:
div.hide {
display: none;
}
When you apply the hide
class to a div
, it will become hidden:
<div class="hide">This content will be hidden.</div>
By setting the display
property to none
, the div
is completely removed from the layout. If you want to make it visible again, you can either remove the hide
class or set its display
property back to block
or another appropriate value.