files/en-us/web/api/selection_api/index.md
{{DefaultAPISidebar("Selection API")}}
[!NOTE] This API is not available in Web Workers (not exposed via {{domxref("WorkerNavigator")}}).
The Selection API enables developers to access and manipulate the portion of a document selected by the user.
The {{domxref("Window/getSelection()", "Window.getSelection()")}} and {{domxref("Document/getSelection()", "Document.getSelection()")}} methods return a {{domxref("Selection")}} object representing the portion of the document selected by the user. A Selection object provides methods to:
The Selection API also provides two events, both firing on {{domxref("Document")}}:
Selection object representing the current selection or current position of the caret.Selection object representing the current selection or current position of the caret.{{Specifications}}