HTML DOM clientTop Property

Last Updated : 19 Aug, 2026

The DOM clientTop Property is used to return the width of the top border to an element in terms of pixel.It does not include the measurement of the width of the top padding or the left margin.It is read-only property.

Syntax

element.clientTop 

Return Value: It returns a numeric value which represent the width of the Top border to an element.

Example

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
    <title>HTML DOM clientTop Property</title>
    <style>
        h1 {
            color: green;
            font-size: 35px;
        }
        #GFG {
            height: 100px;
            width: 350px;
            padding: 20px;
            margin: 25px;
            border-left: 10px solid coral;
            border-top: 15px solid blue;
            background-color: green;
        }
        .title {
            color: white;
            font-size: 25px;
            margin: 0 0 8px;
        }
        #sudo {
            color: white;
            font-size: 13px;
            line-height: 1.3;
            margin: 0;
        }
    </style>
</head>
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>HTML DOM clientTop Property</h2>
        <div id="GFG">
            <p class="title">GeeksforGeeks</p>
            <p id="sudo"></p>
        </div>
<!--Driver Code Ends-->

        <button id="btn">Submit</button>
    </center>
    <script>
        document.getElementById("btn").addEventListener("click", function () {
            var w = document.getElementById("GFG");
            // Using clientTop and clientLeft properties
            var x = "Border Top Width: " + w.clientTop + "px<br>";
            x += "Border Left Width: " + w.clientLeft + "px";
            document.getElementById("sudo").innerHTML = x;
        });
    </script>

<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->
  • element.clientLeft gives the thickness of the left border. It does not include the left margin or left padding. The value is always an integer (rounded).
  • If the element has direction: rtl and a vertical scrollbar appears on the left side due to overflow, the scrollbar width is included in clientLeft. Also, for elements with display: inline, it always returns 0 regardless of any border.
Comment