Think of filling out a sign-up page. Clear fields make the job simple; confusing fields make people leave.
What You Need to Know
Here is a small, realistic example focusing on error summary.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<div role="alert" aria-labelledby="error-heading">
<h2 id="error-heading">Please fix these problems</h2>
<ul><li><a href="#student-email">Enter a valid email address</a></li></ul>
</div>
<form action="/apply" method="post">
<label for="student-email">Email</label>
<input id="student-email" name="email" type="email" aria-invalid="true" aria-describedby="email-error">
<p id="email-error">Please enter a valid email address.</p>
<button type="submit">Submit</button>
</form>
Let’s Read the Code
- <h2>: A heading divides the page into understandable parts.
- <form>: The form groups controls and identifies where submitted data goes.
- aria-labelledby: Aria-labelledby uses the text of another element as the accessible name.
- id: An id uniquely identifies an element on this page.
What the example shows: The markup gives the browser a clear starting point for error summary. Look at the labels, names, and values rather than only the visual appearance.
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) email. 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
Change one meaningful attribute, submit the form, and compare the result with the original.
Common Beginner Mistakes
- Copying the example without giving the fields a clear label and a usable name.
- A browser may render the control differently from another browser without changing the HTML meaning.
Key Takeaways
- With error Summary Linked to Invalid Fields, the main idea is to match the HTML to the visitor’s task, not just to copy an unfamiliar attribute.
- <h2>: A heading divides the page into understandable parts.
- Remember that HTML form rules help the visitor, but server-side code must decide whether received data is valid.