JavaScript Element scrollTopMax Property

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

What You’ll Learn

Element.scrollTopMax is a read-only instance property that returns the maximum top scroll offset possible for an element. Learn what it means, why it is non-standard, how to feature-detect it, and how to replace it with a portable calculation—with five examples and try-it labs.

01

Kind

Instance property

02

Access

Read-only

03

Type

Number (pixels)

04

Status

Non-standard

05

Support

Mainly Firefox

06

Portable alt

scrollHeight - clientHeight

Introduction

scrollTop tells you where a box is scrolled vertically. Sometimes you also need the maximum possible value—for example, to jump to the bottom or to compute scroll progress.

Firefox exposes that maximum as scrollTopMax. Because it is non-standard, this tutorial teaches both the Firefox property and the cross-browser formula you should prefer in real projects.

JavaScript
const box = document.getElementById("notes");

// Non-standard (mainly Firefox):
console.log(box.scrollTopMax);

// Portable alternative:
console.log(box.scrollHeight - box.clientHeight);
💡
Beginner tip

Think of scrollTopMax as “how far down can this box scroll?” In most browsers, that answer is scrollHeight - clientHeight.

Understanding the Property

MDN: the read-only scrollTopMax property returns a number representing the maximum top scroll offset possible for the element.

  • Read-only — inspect the maximum; do not assign to it.
  • Number — pixel value for the farthest vertical scroll position.
  • Non-standard — not in any public web specification.
  • Limited support — mainly Firefox; feature-detect before using.

📝 Syntax

JavaScript
scrollTopMax

Value

A number representing the maximum vertical scroll offset in CSS pixels (where supported).

ItemDetail
TypeNumber (pixels)
AccessRead-only property
StatusNon-standard (MDN)
SpecNot part of any specification
Portable altscrollHeight - clientHeight
⚠️
Always feature-detect

Check "scrollTopMax" in element (or on Element.prototype) before reading it. Otherwise many browsers will return undefined.

📋 Portable Maximum Scroll Pattern

MDN documents scrollTopMax but notes it is non-standard. For real projects, calculate the maximum with standard properties:

JavaScript
function getScrollTopMax(element) {
  if ("scrollTopMax" in element) {
    return element.scrollTopMax;
  }
  return element.scrollHeight - element.clientHeight;
}

Related learning: scrollTop, scrollHeight, clientHeight, and scrollLeftMax (also non-standard).

⚡ Quick Reference

GoalCode / note
Read max (Firefox)el.scrollTopMax
Portable maxel.scrollHeight - el.clientHeight
Feature-detect"scrollTopMax" in el
Jump to bottomel.scrollTop = el.scrollHeight - el.clientHeight
Current positionel.scrollTop
MDN statusNon-standard

🔍 At a Glance

Four facts about Element.scrollTopMax.

Kind
get only

Instance

Type
number

Max offset

Status
non-std

MDN

Prefer
H − C

scrollHeight − clientHeight

Examples Gallery

Examples follow MDN Element: scrollTopMax and focus on feature detection plus the portable alternative so labs work outside Firefox too.

📚 Getting Started

Feature-detect before reading the non-standard property.

Example 1 — Feature-Detect scrollTopMax

Check whether the property exists before reading it.

JavaScript
const box = document.getElementById("notes");
console.log("scrollTopMax" in box);
Try It Yourself

How It Works

In Firefox this may be true. In Chrome, Safari, and Edge it is usually false.

📈 Portable Max, Compare & Jump

Use the standard formula, compare values, and scroll to the bottom.

Example 2 — Portable Maximum Scroll

Calculate the maximum with scrollHeight - clientHeight.

JavaScript
const box = document.getElementById("notes");
const maxTop = box.scrollHeight - box.clientHeight;
console.log(maxTop);
Try It Yourself

How It Works

Total content height minus visible height gives the farthest vertical scroll offset.

Example 3 — Compare Native vs Portable

Where scrollTopMax exists, it should match the portable calculation (aside from rounding).

JavaScript
const box = document.getElementById("notes");
const portable = box.scrollHeight - box.clientHeight;
const native = "scrollTopMax" in box ? box.scrollTopMax : null;
console.log({ portable, native });
Try It Yourself

How It Works

Outside Firefox, native is usually null here because the property is missing.

Example 4 — Jump to Bottom

Scroll all the way to the maximum vertical position using the portable max.

JavaScript
const box = document.getElementById("notes");
const maxTop = box.scrollHeight - box.clientHeight;
box.scrollTop = maxTop;
console.log(box.scrollTop);
Try It Yourself

How It Works

Assigning the maximum to scrollTop moves the visible area to the bottom.

Example 5 — Support Snapshot

Remember the non-standard status and the recommended alternative.

JavaScript
console.log({
  supported: "scrollTopMax" in Element.prototype,
  access: "read-only",
  status: "Non-standard (MDN)",
  prefer: "scrollHeight - clientHeight"
});
Try It Yourself

How It Works

Learn the Firefox property for interviews and legacy code, but ship the portable formula.

🚀 Common Use Cases

  • Finding the farthest vertical scroll position for a list or panel.
  • Jumping to the bottom of a chat window or terms box.
  • Building scroll progress percentages with current scrollTop.
  • Understanding Firefox-only DOM helpers when reading older code.
  • Teaching the difference between current scroll position and maximum scroll range.

🔧 How It Works

1

Content is taller than the box

Vertical overflow creates a scroll range.

Layout
2

Browser knows the max offset

Roughly content height minus visible height.

Range
3

Firefox exposes scrollTopMax

Other browsers usually omit the property.

Non-std
4

Use scrollHeight − clientHeight

That portable formula is the production-safe approach.

📝 Notes

Browser Support

Element.scrollTopMax is marked Non-standard on MDN and is not part of any specification. Support is limited (mainly Firefox). Logos use the shared browser-image-sprite.png sprite from this project. Prefer scrollHeight - clientHeight for portable code.

Non-standard · Limited

Element.scrollTopMax

Read-only maximum vertical scroll offset — Firefox-oriented, not for production cross-browser use.

Limited Non-standard
Mozilla Firefox Supported (non-standard)
Yes
Google Chrome Not available — use scrollHeight - clientHeight
No
Microsoft Edge Not available — use scrollHeight - clientHeight
No
Apple Safari Not available — use scrollHeight - clientHeight
No
Opera Not available — use scrollHeight - clientHeight
No
Internet Explorer Not available
No
scrollTopMax Limited

Bottom line: Feature-detect if you inspect scrollTopMax in Firefox. For shipping UI, use scrollHeight - clientHeight.

Conclusion

scrollTopMax is a convenient Firefox read-only helper for the maximum vertical scroll offset, but it is non-standard. Learn it for understanding and interviews, then ship scrollHeight - clientHeight in real projects.

Continue with scrollTop, scrollHeight, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Prefer scrollHeight - clientHeight in production
  • Feature-detect before reading scrollTopMax
  • Use the max value to jump or measure progress
  • Pair with scrollTop for current position
  • Recompute after content or size changes

❌ Don’t

  • Rely on scrollTopMax as a cross-browser API
  • Skip feature detection
  • Assign el.scrollTopMax = ... (read-only)
  • Confuse max offset with current scrollTop
  • Assume Chromium and Safari implement it

Key Takeaways

Knowledge Unlocked

Five things to remember about scrollTopMax

Non-standard Firefox helper for maximum vertical scroll offset.

5
Core concepts
📝02

number

max offset

Type
🔍03

Non-standard

mainly Firefox

Status
04

Portable

H − C formula

Prefer
🎯05

Detect first

before reading

Tip

❓ Frequently Asked Questions

It is a read-only property that returns the maximum vertical scroll offset possible for the element — the largest value scrollTop can reach.
MDN marks Element.scrollTopMax as Non-standard. It is not part of any specification. It is not labeled Deprecated or Experimental on that MDN page, but it should not be used as a production cross-browser API.
Support is limited. It is mainly available in Firefox. Chrome, Safari, and Edge typically do not provide this property.
Prefer the portable calculation: element.scrollHeight - element.clientHeight. That works across modern browsers.
No. It is read-only. You read the maximum, then assign to scrollTop if you want to move the scrollbar.
scrollTop is the current vertical scroll position and is writable. scrollTopMax is the maximum possible position and is read-only (where supported).
Did you know?

Firefox also has a related non-standard property for the horizontal axis: Element.scrollLeftMax. The portable horizontal alternative is scrollWidth - clientWidth.

Previous: scrollTop

Learn how Element.scrollTop gets or sets vertical scroll position.

← scrollTop

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