HTML spellcheck Attribute
The HTML spellcheck global attribute indicates whether editable text should be checked for spelling and grammar errors. It can enable or disable checking for supported form controls and editable content, although the browser and the user's settings ultimately determine how spellchecking is performed.
Elements That Use the spellcheck Attribute
The spellcheck attribute is a global attribute and can be specified on HTML elements. Spellchecking is primarily useful for elements containing editable text.
| Element | Description |
|---|---|
<input> |
Can control checking for editable text in supported input types. |
<textarea> |
Can control checking of editable multiline text. |
| Editable HTML elements | Can control checking of text inside elements made editable with contenteditable. |
Supported Values
The spellcheck attribute is an enumerated attribute with two keywords: true and false.
| Value | Description |
|---|---|
true |
Indicates that spelling and grammar checking should be enabled when possible. |
false |
Indicates that spelling and grammar checking should be disabled. |
An empty spellcheck value represents the True state. A missing or invalid value uses the Default state, which depends on the element, its ancestors, browser behavior, and user preferences.
Editable Text
Spellchecking is intended for editable text. The HTML standard identifies mutable <input> controls in the text, search, url, and email states, editable <textarea> elements, and text in editing hosts or other editable elements as text that browsers can consider for spelling and grammar checking.
<input type="text" spellcheck="true">
<textarea spellcheck="true"></textarea>
<div contenteditable="true" spellcheck="true">
Edit this text.
</div>
Readonly or disabled form controls are not considered editable for this purpose.
Enabling Spellchecking
Use spellcheck="true" when spelling and grammar checking should be enabled for editable text when the browser supports it.
<textarea spellcheck="true">
Check the spelling of this text.
</textarea>
The browser may identify misspelled words or grammar errors while the user edits the content. The exact interface and checking behavior are determined by the browser and the user's settings.
Disabling Spellchecking
Use spellcheck="false" when spelling and grammar checking should be disabled.
<textarea spellcheck="false">
Spellchecking is disabled for this text.
</textarea>
This can be useful for editable content containing product codes, technical terms, usernames, or other text for which ordinary spelling suggestions may not be useful.
Default Behavior
If the spellcheck attribute is omitted, the element uses its default spellchecking behavior. The HTML standard allows an element's default behavior to be enabled, disabled, or inherited from its parent.
<textarea>
The browser determines the default spellchecking behavior.
</textarea>
Because browser behavior and user preferences can affect spellchecking, do not assume that an editable element will always be checked simply because the spellcheck attribute is omitted.
Inherited Behavior
Spellchecking behavior can be inherited from an ancestor. This makes it possible to enable or disable checking for an editable section and allow descendant content to follow that setting.
<div contenteditable="true" spellcheck="true">
<p>This editable text can be checked for spelling.</p>
<p spellcheck="false">Checking is disabled for this text.</p>
</div>
An explicit spellcheck value on a descendant can override the applicable setting inherited from an ancestor.
Privacy Considerations
Spellchecking can have privacy implications because some browsers or operating-system services may send editable text to an external service to perform enhanced spelling or grammar checking. The HTML specification does not define how the checking service must operate.
Consider using spellcheck="false" for editable fields that may contain sensitive information when sending that content to a spelling service would be inappropriate. The browser's spellchecking implementation and the user's settings ultimately determine how text is processed.
Common Mistakes
Do not treat spellcheck as a Boolean attribute. It is an enumerated attribute, so use spellcheck="true" or spellcheck="false" when explicitly selecting a state.
Do not expect spellcheck="true" to guarantee that spelling errors will be displayed. The attribute provides the requested spellchecking state, but browser capabilities and user preferences can affect the actual behavior.
Do not assume that spellcheck="false" prevents all processing of entered text by every browser, operating system, extension, or input method. It specifically controls the HTML spellchecking hint.
Do not expect the attribute to provide useful spellchecking on ordinary non-editable page content. Spellchecking is intended primarily for editable text.
Browser Support
Baseline: Widely available indicates a feature has been supported by core browsers for at least 30 months. At this stage, the feature is considered stable and safe for most websites to use without needing to worry about compatibility issues or fallbacks, as it is supported by the vast majority of users' devices and browser versions.
The spellcheck global attribute is widely supported in current core browsers. The exact spelling and grammar checking behavior can vary by browser, operating system, language settings, and available checking services.
Checking Browser Support
For current browser compatibility information, visit Can I Use? . Search for the HTML element or attribute you want to check. You can also narrow your search by entering an element name and attribute name separated by a colon. Search results can include related HTML features, element attributes, input types, APIs, and other technologies, so select the result that most closely matches the feature you are checking.
Try the spellcheck Attribute
The example provides two editable text areas containing intentionally misspelled words. The first uses spellcheck="true", while the second uses spellcheck="false". The visible results depend on your browser and spellchecking settings.
Summary
The HTML spellcheck global attribute controls whether editable text should be checked for spelling and grammar errors. The true value enables checking when possible, while false disables it. When the attribute is missing or invalid, default behavior applies and may depend on the element or its ancestors. Browser capabilities, user preferences, language settings, and spellchecking services can affect the actual checking behavior.
