mdn / mdn/content

Caret position not mentioned or demonstrated for setSelectionRange()

Open
#41,590 0 comments 0 reactions 0 assignees View on GitHub
Content:WebAPI
Dominant language
Markdown
Stars
11k
Forks
23.2k
Avg merge
2d 9h
Merged PRs (30d)
331

Description

### MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange

### What specific section or headline is this issue about?

Caret position not mentioned or demonstrated for setSelectionRange()

### What information was incorrect, unhelpful, or incomplete?

The setSelectionRange() method allows moving the caret to a position within a form field element yet the word caret is not mentioned even once on this page, forget about a simple demonstration.

### What did you expect to see?

1. The ability to move the caret for form fields should be mentioned within the first sentence for the setSelectionRange() method.

2. A basic example to move caret to second position would demonstrate something clear (versus start or end).

```

document.getElementById('test').setSelectionRange(2,2);
```

People learn best through multiple iterations, allowing them to easily set the position (0,1,2,3, etc) would help people grasp what is going on much quicker.

### Do you have any supporting links, references, or citations?

_No response_

### Do you have anything more you want to share?

_No response_

### MDN metadata

Page report details

* Folder: `en-us/web/api/htmlinputelement/setselectionrange`
* MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
* GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/htmlinputelement/setselectionrange/index.md
* Last commit: https://github.com/mdn/content/commit/76d6c2c2bcca61d0d14ed464356716090097bc7a
* Document last modified: 2025-07-30T17:14:37.000Z

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.