The selectstart event of the Selection API fires when a user starts a new selection(MDN) — for example dragging to highlight text. Cancel it and the selection is not changed.
Limited availability: not Baseline — missing in some browsers (notably Safari on iOS). Not Deprecated, Experimental, or Non-standard. Prefer CSS user-select when you only need a style-level block.
Remember
document.addEventListener("selectstart", (e) => {
// user began selecting
});
// block selection on this node / document:
e.preventDefault(); // selection is not changed
vs selectionchange → fires after selection updates (not cancelable)
vs getSelection() → read the current Selection object
on selectstart:
if blocking this area:
preventDefault()
// selection stays as it was
else:
// selection may start / update
// later: selectionchange may fire
// read with getSelection()
Reference
Cheat Sheet
Keep these facts handy when working with text selection.
Topic
Detail
Listen
addEventListener("selectstart", fn)
Property
node.onselectstart = fn
Type
Generic Event
Cancel
preventDefault() → selection not changed
API
Selection API
Status
Limited availability (not Baseline)
iOS Safari
Unsupported — test if blocking matters
Try it
Live Preview
Drag across the sample text. Toggle allow vs block (preventDefault on selectstart).
Sample text
Drag to select this sentence — CodeToFun selectstart demo.
Browser demo of selectstart — Limited availability in some browsers.
Result
Choose allow or block, then drag to select…
Code
JavaScript Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Nodeselectstart is marked Limited availability (not Baseline) on MDN. Desktop Chromium, Firefox, and Safari generally support it; Safari on iOS does not.
✓ Limited · Not Baseline
Node selectstart
Fires when a user starts a new selection. Cancel with preventDefault to keep the selection unchanged. Test iOS Safari if blocking selection is critical.
LimitedNot Baseline
Google ChromeSupported · Desktop & Android
Supported
Mozilla FirefoxSupported · Desktop & Android
Supported
Microsoft EdgeSupported · Chromium
Supported
Apple SafariDesktop yes · iOS no
Partial
OperaSupported · Modern versions
Supported
Samsung InternetSupported · Android
Supported
selectstartLimited
Bottom line: Fine for progressive enhancement. Prefer CSS user-select when you only need a style-level block, and always verify on iOS.
Analysis
Performance Notes
Approach
Cost
Best for
selectstart listener
Per selection start
Gate / log begins
selectionchange
May fire often while dragging
Live selected-text UI
CSS user-select
No JS
Simple no-select regions
selectstart is cheap (once per new selection). Avoid heavy work on every selectionchange while the user is still dragging.
Pair:selectionchange + getSelection() to read text.
One line:selectstart is the cancelable “selection began” signal from the Selection API.
Frequently Asked Questions
It is a Selection API event fired when a user starts a new selection (for example dragging to highlight text). If you cancel the event, the selection is not changed (MDN).
No. MDN does not mark Node selectstart as Deprecated, Experimental, or Non-standard. It is labeled Limited availability (not Baseline) because support is missing in some browsers—notably Safari on iOS.
A generic Event. Cancel it with event.preventDefault() to block the new selection from starting.
Use addEventListener("selectstart", handler) or the onselectstart property on document, window, or an element that participates in selection.
selectstart fires when a selection begins (and can be canceled). Document selectionchange fires whenever the selection changes and is not cancelable — use getSelection() inside that listener.
Compatibility data show selectstart unsupported on Safari iOS. Desktop Safari supports it. Always test on your target devices if blocking selection matters.