Skip to content

The spellcheck Attribute

Global Attribute

The spellcheck attribute specifies whether the browser should check the spelling and grammar of text in an element. It’s particularly useful for input fields, textareas, and contenteditable elements where user-entered text should (or shouldn’t) be checked.

<element spellcheck="value">Content</element>
ValueDescription
trueSpell checking is enabled
falseSpell checking is disabled
DefaultInherits from parent or browser default
Result
Result
Result
Result

Use spellcheck="true" for:

  • Text content: Messages, comments, reviews
  • Long-form text: Articles, blog posts, documentation
  • User names: Personal names can have typos
  • Descriptions: Product descriptions, bios
  • General text input: Any natural language content
<textarea spellcheck="true" placeholder="Write your review..."></textarea>
<div contenteditable="true" spellcheck="true">Blog post content...</div>
<input type="text" spellcheck="true" placeholder="Your name">

Use spellcheck="false" for:

  • Email addresses: [email protected] shouldn’t be checked
  • Usernames: Often contain non-words
  • Technical codes: API keys, passwords, tokens
  • URLs: Web addresses aren’t dictionary words
  • Code blocks: Programming code
  • Search fields: Searches may be intentionally misspelled
  • Product SKUs: Model numbers and identifiers
<input type="email" spellcheck="false">
<input type="password" spellcheck="false">
<input type="search" spellcheck="false">
<input type="text" name="sku" spellcheck="false">
<pre contenteditable="true" spellcheck="false"><!-- Code --></pre>

Set spellcheck based on what users will enter:

<!-- Good practices -->
<input type="text" name="fullname" spellcheck="true">
<input type="email" name="email" spellcheck="false">
<input type="tel" name="phone" spellcheck="false">
<textarea name="bio" spellcheck="true"></textarea>
<input type="text" name="username" spellcheck="false">
<pre><code contenteditable="true" spellcheck="false">
const myVariable = 'value';
</code></pre>
<!-- Search: Users might intentionally misspell -->
<input type="search" spellcheck="false">
<!-- Product search: Allow flexible queries -->
<input type="text" placeholder="Search products..." spellcheck="false">
<!-- Feedback form: Check spelling -->
<textarea placeholder="Your feedback..." spellcheck="true"></textarea>

The attribute inherits, so set it on containers:

<form spellcheck="false">
<!-- All inputs inherit spellcheck="false" -->
<input type="text" name="username">
<input type="email" name="email">
<input type="password" name="password">
<!-- Override for specific fields -->
<textarea name="bio" spellcheck="true"></textarea>
</form>

Spell checking doesn’t replace validation:

// Still validate on submit
form.addEventListener('submit', (e) => {
const email = emailInput.value;
if (!isValidEmail(email)) {
e.preventDefault();
showError('Invalid email format');
}
});

Browsers have different defaults:

  • Textareas: Usually enabled by default
  • Input fields: Usually enabled for type="text", disabled for specialized types
  • Contenteditable: Usually enabled by default
  • Inherit: Elements inherit from parent if not specified

Browsers mark spelling errors differently:

  • Red wavy underline: Most common (Chrome, Firefox, Safari)
  • Context menu: Right-click shows suggestions
  • Autocorrect: Mobile browsers may auto-correct
const editor = document.getElementById('editor');
// Enable
editor.spellcheck = true;
editor.setAttribute('spellcheck', 'true');
// Disable
editor.spellcheck = false;
editor.setAttribute('spellcheck', 'false');
// Get current value
console.log(editor.spellcheck); // true or false
// All modern browsers support spellcheck
if ('spellcheck' in document.createElement('input')) {
console.log('Spell check supported');
}
// There are no specific spell check events
// Use input events to handle text changes
editor.addEventListener('input', () => {
console.log('Content changed:', editor.value);
});

Spell checking uses the browser’s or system’s dictionary:

<!-- Spell check uses the language from lang attribute -->
<textarea lang="en" spellcheck="true">Color</textarea>
<textarea lang="en-GB" spellcheck="true">Colour</textarea>
<textarea lang="es" spellcheck="true">Hola</textarea>
<!-- Document in English -->
<html lang="en">
<body>
<!-- Quote in Spanish -->
<blockquote lang="es" contenteditable="true" spellcheck="true">
Buenos días
</blockquote>
</body>
</html>

Screen readers typically:

  • Don’t announce spelling errors automatically
  • Users must navigate character-by-character to find errors
  • Some screen readers have separate spell check commands

Don’t rely only on visual spell check indicators:

<textarea aria-describedby="spell-help" spellcheck="true"></textarea>
<div id="spell-help">
Spelling suggestions appear on right-click or long-press
</div>

On mobile devices:

  • spellcheck: Shows red underlines
  • autocorrect: Automatically fixes typos
<!-- Control both on mobile -->
<input
type="text"
spellcheck="false"
autocorrect="off"
autocapitalize="none">

Mobile keyboards may:

  • Auto-correct despite spellcheck="false"
  • Show suggestions above keyboard
  • Auto-capitalize first letters

Universal support across all modern browsers:

BrowserSupportNotes
ChromeAll versionsUses system dictionary
Firefox2.0+Custom dictionaries supported
Safari3.0+macOS spell checker integration
EdgeAll versionsWindows spell checker
MobileiOS 5+, Android 4+Integrated with system keyboard