HTML DOM Document activeElement property

Definition and usage

activeElement The property returns the HTML element that has received focus.

activeElement The property is read-only.

See also:

Element focus() method

Document hasFocus() method

Example

Get the currently focused element:

const element = document.activeElement.tagName;

Try it yourself

Syntax

document.activeElement

Return value

Type Description
Element The HTML element that has received focus.

Browser support

document.activeElement It is a DOM Level 1 (1998) feature.

All browsers fully support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support 9-11 Support Support Support Support