CSS display: none;
The display: none property is used to hide elements without deleting them. It does not take up any space.
<!DOCTYPE html>
<html>
<head>
<style>
h3 {
display: none;
}
</style>
</head>
<body>
<h2>This heading is visible</h2>
<h3>This is a hidden heading</h3>
<p>The hidden heading does not take up space even after hiding it since we have used display: none;.</p>
</body>
</html>CSS visibility: hidden;
The visibility: hidden property also hides an element, but affects the layout i.e. takes up space. Let us see an example
<!DOCTYPE html>
<html>
<head>
<style>
h3 {
visibility: hidden;
}
</style>
</head>
<body>
<h2>This heading is visible</h2>
<h3>This is a hidden heading</h3>
<p>The hidden heading takes up space even after hiding it.</p>
</body>
</html>