Selection: isCollapsed property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

The Selection.isCollapsed read-only property returns a boolean value which indicates whether or not there is currently any text selected. No text is selected when the selection's start and end points are at the same position in the content.

Keep in mind that a collapsed selection may still have one (or more, in Gecko) Ranges, so Selection.rangeCount may not be zero. In that scenario, calling a Selection object's getRangeAt() method may return a Range object which is collapsed.

Value

A boolean.

Specifications

Specification
Selection API
# dom-selection-iscollapsed

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
isCollapsed

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also