In this section, we will learn what the spellcheck attribute is and how to use it in HTML.
HTML spellcheck Attribute Definition and Usage
The spellcheck attribute is used to specify whether the text content of HTML elements should be checked for spelling errors.
This attribute is mainly used in <input> element of type text as well as <textarea> to highlight the spelling errors while users are entering data into these fields. Also, for other HTML elements that have the `contenteditable` attribute set on, we can use this `spellcheck` attribute there as well.
HTML spellcheck Attribute Syntax
<element spellcheck = “true | false”>
HTML spellcheck Attribute Values
The value we set for the spellcheck attribute could be either `true` or `false`.
- `true`: if the value is set to true, that means the spelling check should be on for the target element.
- `false`: if the value is set to false, that means the spelling check should be off for the target element.
Note: the default value is set to true. This means fields like textbox and textarea will show spelling errors if users typed a misspelled word.
Example: using spellcheck attribute in HTML
In the first textbox, if you put a word with wrong spelling, there won’t be any highlight and this is because the `spellcheck` attribute is set to false for this textbox.