This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The clientLeft read-only property of the Element interface returns the width of the left border of an element in pixels. It includes the width of the vertical scrollbar if the text direction of the element is right-to-left and if there is an overflow causing a left vertical scrollbar to be rendered. clientLeft does not include the left margin or the left padding.
Note: When an element has display: inline, clientLeft returns 0 regardless of the element's border.
An integer.
In the following example, the client area has a white background and a 24px black border-left. The clientLeft value is the distance from where the margin (yellow) area ends and the padding and content areas (white) begin: that is, 24px.
<div id="container">
<div id="contained">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
</p>
</div>
</div>
#container {
margin: 3rem;
background-color: rgb(255 255 204);
border: 4px dashed black;
}
#contained {
margin: 1rem;
border-left: 24px black solid;
padding: 0px 28px;
overflow: auto;
background-color: white;
}
| Specification |
|---|
| CSSOM View Module> # dom-element-clientleft> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
clientLeft |
1 | 12 | 3 | 8 | 3 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1 |
HTMLElement.offsetLeftElement.scrollLeftElement.clientHeightElement.clientWidthElement.clientTopElement.getBoundingClientRect()
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft