Explain Codes LogoExplain Codes Logo

Turn off Chrome/Safari spell checking by HTML/CSS

html
spellcheck
html5-spec
browser-compatibility
Nikita BarsukovbyNikita Barsukov·Mar 8, 2025
TLDR

No more red squiggles! Set the spellcheck attribute to false:

<input type="text" spellcheck="false"> <textarea spellcheck="false"></textarea>

Use this in any tag where spell check needs to go on a vacation.

Battle plan to disable spellcheck

Here's your cheat code to disable spell check for each HTML form:

  1. For single warriors (<input> or <textarea>), use spellcheck="false" as your shield.
  2. Whole army of elements getting hammered by spell check? Use spellcheck="false" on <form>:
<form spellcheck="false"> <!-- Preparing for a spell-free battle --> </form>
  1. CSS, unfortunately, forgot to spell "anti-spellcheck". It can't turn off spell checking.
  2. In React land, remember to camel-case. It's spellCheck={false}:
<input type="text" spellCheck={false} /> <!-- Reacting to no spell check -->
  1. autocomplete="off" and autocorrect="off": The twin brothers who can help tame your wild inputs.
  2. Just like checking exam papers, always cross-verify in all browsers.

User-friendly notes

Before you cannonball into the code:

  • Consider the users: Some users love those red squiggly lines. Enable or disable wisely.
  • Autocomplete and Autocorrect: Don't confuse these friends of spellcheck with the latter.
  • Overriding user settings: Battle of the attributes? User settings might win.

Visualization

Embedded visualization into real HTML/CSS-picture:

<input type="text" spellcheck="false" /> <!-- Red pen ran out of ink!-->

Consider your keyboard (⌨️) on diet, without the extra seasoning of spell check (🖊️🚫):

Before: ⌨️ + 🖊️🔴 = Stressful typing party! After: ⌨️ + 🖊️🚫 = Clean typing spree, no red alarms.

CSS also waves its magic wand, cleaning the slate:

input { /* What corrections? */ -webkit-user-modify: read-write-plaintext-only; }

Unboxing the spellcheck

Peek into the spellcheck attribute:

  • HTML5 Spec: WHATWG's Holy Grail guiding browser behavior including spell checking.
  • Spellcheck Attribute: Introduced in HTML5 and does just what it says.
  • Browsers: Check spellcheck's passport for its browser compatibility.

Traps and pitfalls

While we sail the sea, beware of these common icebergs:

  • Don't use carelessly: Wrongly disabling spell checking could turn your user experience sour.
  • Can't override user settings: User settings may out-power your spellcheck.
  • User Agent Stylesheets: Not all browser styles bow to your whims. Be careful with your content-editable elements.

The 'spell' in spellcheck

Here's your telescope into the universe of spellcheck:

  • Performance: Disabling spell check could potentially make your browser breathe easier.
  • User Efficiency: No more red distractions, users can focus better on their tasks.