Check if an element has CSS overflow

True when either axis is styled to scroll: overflow auto or scroll.

JavaScriptBrowser · DOM Version 1.0.0 · MIT · .md

check-if-an-element-has-css-overflow.js
function hasCssOverflow(element) { const { overflowX, overflowY } = getComputedStyle(element); return [overflowX, overflowY].some(value => ['auto', 'scroll'].includes(value)); }

Usage

Markup

fixture.html
<div id="panel" style="overflow-x: hidden; overflow-y: auto; height: 50px"></div>
<div id="plain"></div>

Script

usage.js
hasCssOverflow(document.querySelector('#panel')); // → true
hasCssOverflow(document.querySelector('#plain')); // → false
getComputedStyle(document.querySelector('#panel')).overflow; // → 'hidden auto'

Lines marked → were executed in headless Chromium against the markup above, and each result was compared with the value shown. Lines marked e.g. are illustrative.

Know the limits

  • The original read the overflow shorthand, which is "hidden auto" when the axes differ, as the last line shows; reading overflowX and overflowY handles both.
  • This says whether the element would scroll, not whether its content overflows; see Check if an element has overflow.

The function above is the code the usage lines run. It does not validate its arguments; add checks where it receives untrusted input.

Source & maintenance

Based on Check if an element has CSS overflow from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.

Reads overflowX and overflowY; the original's shorthand check failed when the axes differ. Executed in Chromium. Original MDX retained as inert source evidence.

Maintained by Oveyon. Source commit: 14b481cf60df. Read the license.

Usage lines executed in headless Chromium against the fixture markup; no external services · reviewed October 28, 2026.

Keep exploring

Type two or more characters. Try “duplicate”, “webhook” or “retry”.