coderef

document.elementFromPoint() and document.elementsFromPoint()Baseline · Widely available

The document.elementFromPoint() and document.elementsFromPoint() methods find the top-most element at a given point in the viewport, or all elements at a given point in the viewport, respectively.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.

Browser support

DesktopChrome
1–42Not supported
43+Supportedsince May 19, 2015
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–45Not supported
46+Supportedsince Apr 26, 2016
Current: 157
Safari
1–11Not supported
11.1+Supportedsince Apr 12, 2018
Current: 27
MobileChrome Android
18–42Not supported
43+Supportedsince May 27, 2015
Current: 155
Firefox Android
4–45Not supported
46+Supportedsince Apr 26, 2016
Current: 157
Safari iOS
1–11Not supported
11.3+Supportedsince Mar 29, 2018
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: elementFromPoint.

Feature detection

JS · check before using
if ("Document" in globalThis && "elementFromPoint" in Document.prototype) {
  // Document.elementFromPoint is available
}

Sub-features

Support for each part of the feature (2). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Document.elementFromPoint112341843.2
Document.elementsFromPoint43794611.1434611.3