What it is
HTML describes the structure and meaning of a page. A heading introduces a section, a link navigates, and a button performs an action. Native form elements already provide many keyboard and accessibility behaviors that a styled generic box does not.
Why you need it
An interface must make sense to browsers, keyboards, and assistive technology as well as to someone looking at it. Meaningful elements reduce the amount of behavior you need to recreate.
How it works
- Write headings and landmarks that describe the page.
- Associate each input with a visible label.
- Use a form and submit button for submission.
- Explain errors in text and connect them to the affected field.
Save this as an HTML file and open it
<!doctype html>
<html lang="en">
<title>Email form</title>
<main>
<h1>Join the mailing list</h1>
<form>
<label for="email">Email address</label>
<input id="email" name="email" type="email" required>
<button type="submit">Continue</button>
</form>
</main>
</html>This demonstrates native labels and validation. It has no signup backend, so do not enter a real address. A production form needs an intentional submission destination, server validation, and error handling.
Good practices and why
- Use native controls first and keep the visual label consistent with the accessible name.
- Test the full interaction using only a keyboard, including error recovery.
Common mistakes
- Using placeholder text as the only label.
- Making a clickable div without button semantics and keyboard behavior.
Try it yourself
Open the example and navigate with Tab. Submit an empty field, then a synthetic invalid address. Add instructions describing the expected format.
What a successful result looks like
The field has an announced label, the button is keyboard-operable, and validation does not erase the entered value.
0 / 6000 characters · Saved on this device. Do not include passwords or private data.
Check your understanding
Answer the understanding check correctly to record exercise completion.
Related interview practice
These scenarios add constraints and follow-up questions to the concepts you just learned.
Further reading
Selected primary references · reviewed 2026-10-09. Examples are educational; use your framework’s documented integration guidance when building a deployed system.