W3cubDocs

/Web APIs

AbstractRange: collapsed property

The read-only collapsed property of the AbstractRange interface returns true if the range's start position and end position are the same.

Value

A boolean value which is true if the range is collapsed. A collapsed range is one in which the start and end positions are the same, resulting in a zero-character-long range.

Example

js

let isCollapsed = range.collapsed;

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
collapsed 90 9018–79 69 No 76 14.1 90 90 79 64 14.5 15.0

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AbstractRange/collapsed