JavaScript Element clientLeft Property

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline
Instance property

What You’ll Learn

Element.clientLeft is a read-only instance property that returns the width of an element’s left border in pixels. Learn what it includes and excludes, why display: inline returns 0, and how it pairs with clientTop—with five examples and try-it labs.

01

Kind

Instance property

02

Access

Read-only

03

Type

Integer (px)

04

Measures

Left border

05

Excludes

Padding ยท margin

06

Status

Baseline widely

Introduction

The client area is the padded content box inside the borders. clientLeft tells you how wide the left border is—the gap from the outer edge of the border to where the padding/content starts.

It does not include left margin or left padding. In rare RTL + overflow cases, a left vertical scrollbar width can be included too.

JavaScript
const el = document.getElementById("contained");
console.log(el.clientLeft); // e.g. 24 for border-left: 24px
💡
Beginner tip

Remember: clientLeft = left border width. Padding and margin are measured by other layout APIs.

Understanding the Property

MDN: 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 is right-to-left and overflow causes a left vertical scrollbar. It does not include the left margin or the left padding.

  • Read-only — change CSS borders, then read again.
  • Integer pixels — left border thickness.
  • Inline caveatdisplay: inline always returns 0.
  • Baseline — widely available since July 2015 (MDN).

📝 Syntax

JavaScript
clientLeft

Value

An integer: the left border width in pixels (plus an RTL left scrollbar when applicable).

ItemDetail
Typenumber (integer pixels)
AccessRead-only
IncludesLeft border (and RTL left scrollbar if present)
ExcludesLeft padding, left margin
⚠️
display: inline

When an element has display: inline, clientLeft returns 0 even if a border is styled. Use a block-level box to measure borders this way.

📋 MDN Border Example Shape

MDN uses a box with a 24px black left border. The white client area starts after that border, so clientLeft is 24:

JavaScript
#contained {
  margin: 1rem;
  border-left: 24px black solid;
  padding: 0 28px;
  overflow: auto;
  background-color: white;
}
JavaScript
const el = document.getElementById("contained");
console.log(el.clientLeft); // 24

Related learning: clientTop, clientHeight, clientWidth, and getBoundingClientRect().

⚡ Quick Reference

GoalCode / note
Read left borderel.clientLeft
Top borderel.clientTop
Inner sizeel.clientWidth / el.clientHeight
Inline elementsReturns 0
MDN statusBaseline Widely available

🔍 At a Glance

Four facts about Element.clientLeft.

Kind
get only

Instance

Type
integer

Pixels

Measures
border

Left side

Baseline
widely

Jul 2015+

Examples Gallery

Examples follow MDN Element: clientLeft. Labs use a block box with a thick left border so the value is easy to predict.

📚 Getting Started

Read a 24px left border and see the inline exception.

Example 1 — Read clientLeft

MDN shape: a box with border-left: 24px.

JavaScript
const el = document.getElementById("contained");
console.log(el.clientLeft); // 24
Try It Yourself

How It Works

The left border width becomes the clientLeft value. Padding to the right of that border does not change it.

Example 2 — Inline Elements Return 0

Even with a styled border, display: inline reports zero.

JavaScript
const span = document.getElementById("label");
console.log(span.clientLeft); // 0 when display:inline
Try It Yourself

How It Works

Switch to inline-block or block if you need border measurements via the client* properties.

📈 What Is Excluded, Pairing & Snapshot

Confirm padding/margin are ignored, then pair with clientTop.

Example 3 — Padding and Margin Do Not Count

Large padding/margin leave clientLeft equal to the border only.

JavaScript
const el = document.getElementById("box");
// border-left: 12px; padding-left: 40px; margin-left: 30px
console.log(el.clientLeft); // 12
Try It Yourself

How It Works

This is the key beginner gotcha: client* border offsets are about borders, not spacing.

Example 4 — Pair With clientTop

Read both border offsets together.

JavaScript
const el = document.getElementById("box");
console.log({
  clientLeft: el.clientLeft,
  clientTop: el.clientTop,
  clientWidth: el.clientWidth,
  clientHeight: el.clientHeight
});
Try It Yourself

How It Works

Together, these properties describe the client rectangle relative to the border box.

Example 5 — Support Snapshot

Feature-detect and remember the measurement rules.

JavaScript
console.log({
  supported: "clientLeft" in Element.prototype,
  measures: "left border width (px)",
  tip: "Inline elements return 0; padding/margin are excluded",
  status: "Baseline Widely available (MDN)"
});
Try It Yourself

How It Works

Use clientLeft when you specifically need the left border thickness from layout.

🚀 Common Use Cases

  • Measuring thick accent borders for custom layout math.
  • Converting between border-box and client-area coordinates.
  • Debugging unexpected offsets when borders are uneven.
  • Pairing with clientTop for 2D border thickness.
  • Teaching the difference between border, padding, and margin.

🔧 How It Works

1

CSS defines the left border

border-left-width is part of the box model.

CSS
2

Layout builds the client area

Padding and content sit inside the borders.

Layout
3

clientLeft reads the left border

Optionally plus an RTL left scrollbar.

Measure
4

You get an integer

Use it for offsets, debugging, and box-model teaching.

📝 Notes

Browser Support

Element.clientLeft is Baseline Widely available (MDN: across browsers since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.

Baseline Widely available

Element.clientLeft

Read-only integer โ€” width of the left border in pixels (excludes padding/margin).

Baseline Widely available
Google Chrome Supported
Yes
Microsoft Edge Supported
Yes
Mozilla Firefox Supported
Yes
Apple Safari Supported
Yes
Opera Supported
Yes
Internet Explorer Supported
Yes
clientLeft Baseline

Bottom line: Use clientLeft for left border thickness. Remember inline elements return 0. Pair with clientTop for top border width.

Conclusion

clientLeft is a simple border measurement: the left border width in pixels. Skip padding and margin, watch out for inline elements, and pair it with clientTop when you need both axes.

Continue with clientTop, clientHeight, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use it to read left border thickness
  • Measure block / inline-block boxes
  • Pair with clientTop for 2D borders
  • Re-read after CSS border changes
  • Remember RTL scrollbar edge cases

❌ Don’t

  • Expect padding or margin to be included
  • Trust the value on display: inline
  • Assign to clientLeft (read-only)
  • Confuse it with offsetLeft (position)
  • Forget borders can be asymmetric

Key Takeaways

Knowledge Unlocked

Five things to remember about clientLeft

Read-only left border width in pixels—not padding, not margin.

5
Core concepts
📝 02

Integer px

left border

Type
🔍 03

Box offsets

layout math

Use
04

Baseline

widely available

Status
🎯 05

Not inline

returns 0

Tip

❓ Frequently Asked Questions

It returns the width of the element's left border in pixels. It does not include left margin or left padding.
No. MDN marks Element.clientLeft as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
No. It is a read-only instance property. Change the border with CSS, then read clientLeft again.
When there is no left border, or when the element has display: inline (MDN notes inline elements always return 0).
Yes. If the element is right-to-left and overflow creates a vertical scrollbar on the left, that scrollbar width is included.
clientLeft is the left border width; clientTop is the top border width. Together they describe the client area's border offset.
Did you know?

In MDN’s demo, the yellow area is margin and the white area is the client box. clientLeft is the black left border between them—24px in that example.

Next: clientTop

Learn how to read an element’s top border width in pixels.

clientTop →

About the author

Mari Selvan M P
Mari Selvan M P ๐Ÿ”—

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful