<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
border: 1px solid black;
background-color: lightblue;
width: 300px;
height: 300px;
position: relative;
top: 20px;
}
</style>
</head>
<body>
<h1>Change position with JavaScript</h1>
<p>Click the "Try it" button to change the position property of the DIV element:</p>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
<p>This DIV element is placed 20 pixels from the top of its original position.</p>
<p>Click the button to set the position property to "absolute" and see what happens.</p>
<p>It will then be placed 20 pixels from the top the page.</p>
</div>
<script>
function myFunction() {
document.getElementById("myDIV").style.position = "absolute";
}
</script>
</body>
</html>