HTMLElement: spellcheck property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thespellcheck property of theHTMLElement interface represents a boolean value that controls thespell-checking hint. It is available on all HTML elements, though it doesn't affect all of them.
It reflects the value of thespellcheck HTML global attribute.
In this article
Value
A boolean value that istrue if the spelling and grammar of the text content in the element may be checked,false otherwise.
Examples
The following example shows how to control thespell-checking hint via script:
html
<div> <span>The spelling and grammar may be checked: </span> <span contenteditable="true" spellcheck="true">test</span></div><input type="checkbox" checked />Enable spelling and grammarcheckjs
const label = document.getElementById("sc-label");const element = document.getElementById("sc-element");const controller = document.getElementById("sc-controller");controller.addEventListener("change", (e) => { if (controller.checked) { element.spellcheck = true; label.innerText = "The spelling and grammar may be checked: "; } else { element.spellcheck = false; label.innerText = "The spelling and grammar may not be checked: "; }});Note that you must enable the browser setting to check spelling and grammar.
Specifications
| Specification |
|---|
| HTML> # dom-spellcheck-dev> |
Browser compatibility
See also
spellcheckHTML global attribute