An element can be hidden by setting the display property to none.
This property hides element in such a way that when the page will be displayed it is displayed as if the element is not there.
The layout is as there was no such element.
<!DOCTYPE html>
<html>
<head>
<style>
h1.hidden {
display: none;
}
</style>
</head>
<body>
<h1>This is a visible heading</h1>
<h1 class="hidden">This is a hidden heading</h1>
<p>Notice that the h1 element with display: none; does not take up any space.</p>
</body>
</html>
visibility:hidden:
An element can be hidden by setting the visibility property to hidden.
This property hides element in such a way that when the page will be displayed it is displayed as if the element is there i.e it takes up the same space as before.
<!DOCTYPE html>
<html>
<head>
<style>
h1.hidden {
visibility: hidden;
}
</style>
</head>
<body>
<h1>This is a visible heading</h1>
<h1 class="hidden">This is a hidden heading</h1>
<p>Notice that the hidden heading still takes up space.</p>
</body>
</html>
0 Comment(s)