Disable spell-checking on HTML textfields
To switch off spell-checking on any <input>
or <textarea>
fields, insert the attribute spellcheck="false"
. Like snapping your fingers to turn off the lights, this command immediately tells the browser not to flag any typos for these elements.
Turn off all the bells and whistles
More than one way to disable
Along with spellcheck="false"
, there are other attributes to consider for a complete disabling experience: autocomplete="off"
, autocorrect="off"
, and autocapitalize="off"
. These commands are like your browser's "Do Not Disturb" mode.
autocomplete="off"
Switched off autocomplete. No more unsolicited advice!
autocorrect="off"
Autocorrect, step aside. Humans take control!
autocapitalize="off"
The first word of every sentence, breathe. We've got this.
Device & tag applicability
For a widespread effect on both desktop and mobile browsers, and across <input>
and <textarea>
tags, put these attributes into play.
Know the boundaries of JavaScript
JavaScript is a great tool, but it cannot bulldoze over users' preferences in their browser settings. Shhh, JavaScript, we know you're powerful, but in this case, the user's will prevails!
Dealing with stubborn browsers
Be aware, some browsers like to play by their own rules and might ignore or override our precious spellcheck
attribute in their settings. It's like arguing with a stubborn cat; sometimes they just won't budge.
Attribute placement is key
Insert the spellcheck
attribute within the opening tag of your element. Think of this as organizing a party; you wouldn't hide the theme until your guests arrived!
Before you hit the disable button
Pausing for a moment... is this the best user experience? As developers, we want to make life easier for our users. Don't toss out the flashlight before considering if it's still dark!
Check the compatibility list
Don't forget to check browser compatibility for these attributes. Often times, the expected behaviour of HTML attributes can vary by browser. Its like checking the guest list at an event to avoid any surprises!
Mobile devices' love for autocorrection
On mobile browsers, especially iOS ones, autocorrect tends to take more liberties than we'd like. Including autocorrect="off"
tames this rowdy cowboy for a smoother ride.
HTML5's blessing
The use of the spellcheck
attribute isn't some undocumented trick, but a part of the official HTML5 specification. That's right, it comes with HTML5's seal of approval.
Be mindful of accessibility
Factor in the impact of these changes on accessibility when using forms. Disabling helpful features like spell-checking could disorient some users. It's a bit like taking down the handrail in the stairwell.
Keep your users informed
Should you decide to disable spell-check, providing hints or labels that inform users about this can improve their experience. It's like letting someone know beforehand if the elevator is out of service.
Was this article helpful?