Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<style> 
button {
  margin-bottom: 10px;
}
#myDIV {
  background-color: lightblue;
  border: solid black 1px;
}
.redDiv {
  background-color: rgb(239, 135, 88);
  text-align: center;
}
</style>
</head>
<body>
<h1>Change margin-block-start with JavaScript</h1>
<p>Click the "Try it" button to change the margin-block-start of the blue DIV element:</p>
<button onclick="myFunction()">Try it</button>
<div class="redDiv">div</div>
<div id="myDIV">
This is my DIV element.
</div>
<div class="redDiv">div</div>
<script>
function myFunction() {
  document.getElementById("myDIV").style.marginBlockStart = "20px";
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/cssref/tryit.php?filename=trycss_js_margin-block-start by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:37:23 GMT -->
</html>