HTML5
HTML Spell Check
The spellcheck attribute is a global HTML5 attribute that controls whether the browser checks spelling and grammar on editable content, such as a <textarea>, an <input>, or an element with contenteditable. Set it to true to enable checking or false to disable it.
How spellcheck Works
spellcheck accepts the values true or false. When true, the browser underlines misspelled words in editable fields. When false, spell checking is turned off for that element. It applies to editable controls — plain, non-editable text is not checked.
| Value | Effect |
|---|---|
| true | Enable spell checking on the element |
| false | Disable spell checking on the element |
| (omitted) | Uses the browser/element default |
Runnable Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spellcheck Demo</title>
</head>
<body>
<h2>Spell check ON — type a misspelled word</h2>
<textarea spellcheck="true" rows="3" cols="40">Try typing recieve or wierd here.</textarea>
<h2>Spell check OFF</h2>
<textarea spellcheck="false" rows="3" cols="40">No red underlines here.</textarea>
<h2>Editable div with spell check</h2>
<div contenteditable="true" spellcheck="true"
style="border:1px solid #ccc; padding:8px;">
Click and type to edit this text.
</div>
</body>
</html>spellcheck is a hint — the exact behaviour depends on the browser and the user's language settings. It only affects editable elements like input, textarea, and contenteditable regions.
When to Disable Spell Check
- Fields for codes, usernames, or serial numbers.
- Programming code editors where red squiggles are noise.
- Fields where words are intentionally non-dictionary.
Key Takeaways
- spellcheck is a global attribute with values true or false.
- It enables or disables browser spell checking on editable content.
- It only affects input, textarea, and contenteditable elements.
- Disable it for codes, usernames, and code editors.
