HTML spellcheck Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Forms & Input

Introduction

The spellcheck attribute lets you control whether the browser should check spelling in editable text. When enabled, misspelled words are often marked with a red underline so users can fix them before submitting a form or publishing content.

spellcheck is a global attribute, but it only affects elements where the user can type or edit text—such as <textarea>, text-like <input> fields, and elements with contenteditable. It is a hint to the browser; users can still override spell checking in their browser or OS settings.

What You’ll Learn

01

true / false

Boolean values.

02

textarea

Long-form text.

03

contenteditable

Rich text areas.

04

When to off

Code & usernames.

05

JavaScript

.spellcheck property.

06

Browser UX

Hints, not rules.

Purpose of spellcheck

The primary purpose of the spellcheck attribute is to tell the browser whether to perform spell checking on text inside an editable element. Most browsers enable spell checking by default on fields like <textarea>, but you can turn it off when underlines would be unhelpful—for example on code editors, product SKUs, or usernames that are not dictionary words.

Spell checking improves writing quality in comments, bios, and message boxes. It is not a substitute for server-side validation or grammar tools; it is a lightweight, built-in UX feature that runs locally in the user’s browser.

💡
A hint, not a guarantee

Even with spellcheck="true", the browser may skip checking if the user disabled spell check globally, if the field type does not support it, or if the language dictionary is unavailable. Always design forms so they work without relying on red underlines.

📝 Syntax

Add spellcheck to any editable element with true or false:

spellcheck.html
<!-- Spell checking on (common for textarea) -->
<textarea spellcheck="true"></textarea>

<!-- Spell checking off (usernames, code) -->
<input type="text" spellcheck="false">

<!-- contenteditable region -->
<div contenteditable="true" spellcheck="true">Edit me</div>

Syntax Rules

  • Valid values: true or false (boolean attribute semantics).
  • If omitted, the browser uses its default for that element (often enabled on textarea).
  • Only affects editable elements; it has no effect on plain static text nodes.
  • Can be inherited: child editable nodes may inherit the parent’s spell-check state.
  • In JavaScript, use the boolean property element.spellcheck, not a string.
  • Does not validate grammar or block form submission—it only marks possible typos visually.

💎 Values

The spellcheck attribute accepts two enumerated values:

  • spellcheck="true" — Ask the browser to check spelling in this editable element.
  • spellcheck="false" — Ask the browser not to check spelling (no red underlines from spell check).
  • Omitted — Browser default applies; typically on for textarea and many contenteditable regions.
spellcheck-values.html
<textarea spellcheck="true">Comment with spell help</textarea>

<input type="text" spellcheck="false" name="handle">

<div contenteditable="true" spellcheck="false">
  Code snippet: const foo = bar;
</div>

⚡ Quick Reference

TopicDetailExample
TypeBoolean enumeratedtrue / false
ScopeGlobal attributeEditable elements only
Common ontextarea, inputspellcheck="true"
Turn off forUsernames, code, tokensspellcheck="false"
JavaScriptel.spellcheck = falseBoolean property
Not validationVisual hint onlyValidate on server too

Applicable Elements

ElementEffect?Notes
<textarea>YesMost common use; often enabled by default
<input type="text">Yessearch, email, url, tel also support editing
contenteditableYesRich text editors, inline editing
<input type="password">Usually offBrowsers typically disable spell check for security
<input type="number">NoNot meaningful for numeric fields
Static <p>, <div>NoUnless contenteditable is set

spellcheck vs validation vs autocorrect

Featurespellcheckrequired / patternMobile autocorrect
PurposeMark spelling mistakesEnforce form rulesOS keyboard suggestions
Blocks submit?NoYes when invalidNo
Controlled byHTML attributeHTML + browser validationDevice / browser settings
Turn off withspellcheck="false"Remove constraint attrsautocorrect="off" (mobile)

Examples Gallery

contenteditable with spellcheck on vs off, JavaScript toggle, and form fields (textarea / input).

👀 Live Preview

Two editable boxes—spellcheck enabled on the first, disabled on the second. Type a misspelled word to compare:

Try typing teh or recieve here.
Same mistakes should not be underlined.

Underline behavior depends on your browser language settings.

Example — contenteditable Regions

Enable or disable spell checking on editable <div> elements:

spellcheck.html
<div contenteditable="true" spellcheck="true">
  <p>Editable content with spell-checking enabled.</p>
</div>

<div contenteditable="true" spellcheck="false">
  <p>Editable content with spell-checking disabled.</p>
</div>
Try It Yourself

How It Works

Both div elements are editable via contenteditable="true". The spellcheck attribute tells the browser whether to run its dictionary check on typed text inside each region.

Dynamic Values with JavaScript

Toggle spell checking at runtime with the spellcheck IDL property:

dynamic-spellcheck.html
<div id="dynamicElement" contenteditable="true" spellcheck="true">
  Type here...
</div>
<button type="button" id="toggleBtn">Toggle spellcheck</button>

<script>
  var el = document.getElementById("dynamicElement");
  document.getElementById("toggleBtn").addEventListener("click", function () {
    el.spellcheck = !el.spellcheck;
  });
</script>
Try It Yourself

How It Works

The JavaScript property is a boolean. Assign false to stop new spell-check underlines; assign true to re-enable checking. Useful when switching between “plain text” and “code” modes in one editor.

Example — textarea and input

Use spellcheck on prose fields and turn it off for identifiers:

form-spellcheck.html
<label for="bio">Bio:</label>
<textarea id="bio" spellcheck="true"></textarea>

<label for="username">Username:</label>
<input type="text" id="username" spellcheck="false">
Try It Yourself

How It Works

Long-form fields benefit from spell help; short identifier fields often disable it so valid handles are not flagged as dictionary errors.

♿ Accessibility

  • Do not rely on color alone — Red underlines help sighted users; screen readers may not announce them. Provide clear labels and error messages for required content.
  • Label editable fields — Associate <label> with textarea and input so users know what to type.
  • Disable for assistive tech conflicts — In custom rich-text widgets, test with keyboard and screen readers when toggling spellcheck.
  • Language attribute — Set lang on the page or field so the browser picks the correct dictionary.
  • Respect user preferences — Users may disable spell check globally; your UI should remain usable either way.

🧠 How spellcheck Works

1

Author sets spellcheck

true or false on field.

Markup
2

User types text

In editable element.

Input
3

Browser checks words

Dictionary + language.

Spell check
=

Visual feedback

Underlines on typos.

Browser Support

The spellcheck attribute is supported in all modern browsers on editable elements. Exact underline styling and dictionary behavior may vary.

HTML5 · Fully supported

Built-in spell checking

Chrome, Firefox, Safari, and Edge honor spellcheck on supported fields.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
spellcheck attribute 99% supported

Bottom line: Use spellcheck confidently; test across browsers and languages for your audience.

💡 Best Practices

✅ Do

  • Enable spellcheck on comments, bios, and long-form text areas
  • Disable it on usernames, URLs, code, and technical tokens
  • Set lang so the correct dictionary is used
  • Test with typos in Chrome, Firefox, and Safari
  • Toggle with JavaScript when switching editor modes

❌ Don’t

  • Assume spellcheck="true" blocks invalid submissions
  • Rely on underlines as your only form validation
  • Enable spellcheck on password fields (browsers usually ignore it anyway)
  • Confuse spellcheck with mobile autocorrect
  • Expect identical underline UI in every browser

Conclusion

The spellcheck attribute is a practical way to control browser spell checking on editable HTML elements. Used well, it helps users catch typos in prose fields while staying out of the way in code and identifier inputs.

Pair it with clear labels, proper lang attributes, and server-side validation for a complete input experience. Toggle it dynamically when your UI switches between content types that benefit from different checking behavior.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about spellcheck

Bookmark these before your next form or editor.

5
Core concepts
📝 02

Editable only

textarea, input

Scope
💬 03

UX hint

Red underlines

Behavior
⚙️ 04

.spellcheck

JS toggle

Dynamic
🔒 05

Off for code

Usernames too

Practice

❓ Frequently Asked Questions

It tells the browser whether to check spelling in an editable element and mark possible mistakes, usually with a red underline.
textarea, text-like input types, and any element with contenteditable. It is a global attribute but only affects editable content.
When omitted, the browser decides. Many browsers enable spell check on textarea by default, but you should set true or false explicitly when the behavior matters.
Disable it for code snippets, usernames, product codes, and any field where dictionary words are not expected.
Yes. Set element.spellcheck = true or false using the boolean IDL property.
Yes in all modern browsers on supported editable elements. Visual details and dictionaries may differ by browser and language.

Control spell checking in your forms

Practice spellcheck="true" and false in the Try It editor.

Try contenteditable demo →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful