Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
    height: 250px;
    width: 400px;
    padding: 10px;
    margin: 15px;
    border-top: 15px solid black;
    border-left: 10px solid red;
    background-color: lightblue;
}

</style>
</head>
<body>

<p>Click the button to get the width of the div's top and left border, in pixels.</p>

<button onclick="myFunction()">Try it</button>

<div id="myDIV">
  <p id="demo"></p>
</div>

<script>
function myFunction() {
    var elmnt = document.getElementById("myDIV");
    var txt = "Border top width: " + elmnt.clientTop + "px<br>";
    txt += "Border left width: " + elmnt.clientLeft + "px";
    document.getElementById("demo").innerHTML = txt;
}
</script>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy