A form should feel easy to use. The visitor sees a question, gives an answer, and needs to know what will happen next.
What You Need to Know
Spelling suggestions can help with prose but may be distracting for codes and identifiers.
In this example: disable spellcheck in a username input.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<label for="journal">Journal entry</label>
<textarea id="journal" name="journal" spellcheck="true" rows="4"></textarea>
<label for="product-code">Product code</label>
<input id="product-code" name="product-code" spellcheck="false">
Let’s Read the Code
- <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
- <textarea>: The textarea accepts several lines of text.
- for: For connects a label or output with a control by ID.
- id: An id uniquely identifies an element on this page.
Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.
What Happens in the Browser?
The HTML controls work in the browser, but saving an answer requires the example action path to be handled by a real server.
Where does the answer go? The example uses the submitted name(s) journal, product-code. Those names help the receiving server identify each answer. A label is for people; a name attribute is for the form data; an ID connects elements in the page.
Your Turn
Type a made-up word in both fields and compare the browser suggestions.
Common Beginner Mistakes
- Copying the example without giving the fields a clear label and a usable name.
- A spellcheck setting does not mean the browser will correct submitted data.
Key Takeaways
- Choose the HTML feature that explains this task clearly.
- <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
- Test the behavior you expect rather than trusting how the snippet looks in your editor.