Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
  margin: auto;
  width: 400px;
  height: 200px;
  background-color: lightblue;
  border: 1px solid black;
}
</style>
</head>
<body>
<h1>Change visibility with JavaScript</h1>
<p>Click the "Try it" button to set the visibility property of the DIV element to "hidden":</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">This is my DIV element.</div>
<p><strong>Note</strong>: Hidden elements still take up space on the page.</p>
<script>
function myFunction() {
  document.getElementById("myDIV").style.visibility = "hidden";
}
</script>
</body>
</html>