Signup/Sign In

Using spellcheck Attribute - HTML Forms

Posted in Programming   LAST UPDATED: SEPTEMBER 30, 2021

    The spellcheck attribute in HTML Form is used to check spelling mistakes of user input in text fields. This attribute is used with input and teaxtarea HTML elements, where we can use the spellcheck attribute, and the user input value can be checked for grammatical and spelling mistakes.

    Syntax for spellcheck attribute:

    Following is the syntax for using the spellcheck attribute,

    If you want to use it in the input text field:

    <input type="text" spellcheck="true|false" />

    If you want to use it in the textarea field:

    <textarea spellcheck="true|false"> ... </textarea>

    The spellcheck attribute values:

    Value Description
    true It defines if the user input is to have its spelling and grammar checked.
    false It defines if the user input is not being checked.

    Following things may be spellchecked:

    • The text values in input elements.

    • The text in <textarea> elements.

    • The text in editable elements.


    Time for an Example!

    Now we are going to show you some code for the in-depth understanding of spellcheck attribute:

    Explanation of code:

    A form is created in the output with two textareas. In the first textarea spellcheck is turned off while in the second textarea, spell check is turned on.

    In the output, you can see if you enter text in both textareas to check spelling mistakes. The first text area does not display any sign for spelling mistakes, whereas the second textarea displays a red wavy line under the word with spelling errors. All this is because we set the spellcheck attribute's value to false for the first textarea while for second textarea spellcheck attribute is set to true.

    In the above code:

    1. contenteditable: It is an attribute that describes if the content of an element is editable or not.

    2. spellcheck: It is an attribute which informs the browser whether the element have its grammar and spelling checked or not.


    Browser Support for spellcheck attribute:

    Following browsers support this attribute:

    • Google Chrome 9.0

    • Internet Explorere 11.0

    • Firefox

    • Opera

    • Safari

    You may also like:

    About the author:
    Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.
    Tags:HTML5spellcheck AttributeHTML FormHTML
    IF YOU LIKE IT, THEN SHARE IT
     

    RELATED POSTS