Skip to Content
Platform.Ontology

Text selection and caret

Lets the page see what is selected inside itself and move the cursor; nothing outside the page.

Gets silentlyTyping and clipboardTextWeb browsersWhile you use it

In one line

Can see which of its own words you highlight and move your text cursor

Lets the page see what is selected inside itself and move the cursor; nothing outside the page.

A site knows which of its own words the person highlights, which reveals interest and reading focus. It cannot see a selection in another tab or app.

What it can and can't do

What the user does: You highlight text or click in a box on the page

It can

  • See the text you select on the page
  • Move the cursor or change the selection on its own page
  • Guess what you are interested in from what you highlight

It cannot

  • See selections in other tabs or apps
  • See what you select when the page is in the background
  • Show a permission pop up; there is none

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported12008-12-11None
EdgeSupported122015-07-29None
FirefoxSupported12004-11-09None
SafariSupported12003-06-23None
Safari on iPhoneSupported12007-06-29All iOS browsers use WebKit
Chrome on AndroidSupported182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APIwindow.getSelection(); selectionchange event; input.selectionStart; Range.getBoundingClientRect()
Browser compat keysapi.Window.getSelection
api.Document.selectionchange_event
api.Selection
How access is grantednone
What the user seesNone (no browser prompt)
Needs a secure context (HTTPS)No
Needs a user gestureNo
Activationnone
How long it lastsLive while the page has focus
How to take it backNothing to revoke (no permission is stored)
Inside an iframeFrames see only their own selection; selection in a cross-origin iframe is hidden from the parent

Typical flow

  1. Person selects text
  2. selectionchange fires on the document
  3. Page reads the Selection and Range

Data you get

Shape: none

No individual data fields. The signal is the access itself.

Technical limits

  • Sees selection inside its own document (and same-origin frames) only
  • Cannot read the selection from the address bar, other tabs, other apps or browser UI
  • Password fields: selected text of a password input is not exposed by getSelection().toString() but is readable via the field's value to the page owner
  • selectionchange has no rate limit; it can fire many times per second while dragging
  • Firefox returns the selection inside inputs only through selectionStart and selectionEnd

The story

What it is

The page sees which of its own words you highlight and where your text cursor is.

For you

You highlight text to copy, look up or share. A small menu may pop up near it. You did not know the page could tell which words you picked. It cannot see selections in other tabs or apps.

For makers

Makers use selection to show a share, quote or highlight menu. Reading apps remember highlights and analytics tools learn what people find interesting.

Where you see it

TypeExampleApps
mediaA long read site shows a 'share this quote' button when a reader highlights a sentence.Medium, The Atlantic
educationAn e-reader or course page saves a student's highlights and notes for later.Kindle Cloud Reader, Perusall
productivityA document editor uses selection to show a bold or link toolbar.Google Docs, Notion
gamesA word game or learning site checks which word a player picked from a passage.None named
analyticsA publisher counts which lines get highlighted most to see what resonates.None named
adsA dictionary or search widget can show an ad or lookup for the exact words you picked.None named

Risks

  • Reveals what you find interesting
  • Highlights recorded

Good uses and abuse

Legitimate uses

  • Quote and share tools
  • Dictionary lookups
  • Rich text editors

Known abuse

  • Tracking what people highlight (reading attention)

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2011, Firefox 8: selectionchange event

Sources

How well checked: Based on official documentation.

On this page