Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM clientLeft property

HTML DOM clientLeft property

Element Object Reference Element object

Example

Get the width of the top and left borders of the div element:

var

elmnt

=

document

.

getElementById

(

"

myDIV

"

)

;

var

txt

=

"

The width of the top border:

"

elmnt

.

clientTop

"

px

"

;

txt

+=

"

The width of the left border:

"

elmnt

.

clientLeft

"

px

"

;

Try it »


Definition and Usage

clientLeft represents the width of the left border of an element, measured in pixels. If the element's text direction is right-to-left (RTL, right-to-left) and a vertical scrollbar appears on the left due to content overflow, this property includes the width of the scrollbar.

clientLeft does not include the left margin and left padding.

Tip: You can use the style.borderLeftWidth property to get the width of the element's left border.

Tip: To return the width of the element's top border, you can use clientTop attribute.

clientLeft is read-only.


Browser support

property
clientLeft Yes Yes Yes Yes Yes

Syntax

element.clientLeft 

Technical Details

Return Value: Returns an integer representing the width of the element's left border.

More examples

Example

In the following example, the text direction of the div element is right-to-left and it has a scrollbar:

var

left

=

document

.

getElementById

(

"

myDIV

"

)

.

clientLeft

;

Try it »


Element Object Reference Element object