Inline vs Summary Error Patterns
You'll learn when to display error messages next to individual form fields versus at the top of the form, and how to implement both accessibly.
When form validation fails, you have two main approaches for showing errors: inline errors appear directly next to (or near) the field that failed validation, while summary errors collect all problems in a single list, typically at the top of the form.
When to Use Each Pattern
Inline errors work best for:
- Real-time or field-level validation feedback
- Helping users correct problems immediately after leaving a field
- Short forms where errors are easy to spot
- Mobile screens where scrolling is common
Think of inline errors like a teacher marking mistakes directly on your paper—you see exactly where the problem is.
Error summaries work best for:
- Form-wide validation after submission
- Long forms where errors might be off-screen
- Multiple related errors that need context
- Providing a quick overview of what needs fixing
Think of a summary like a report card listing all issues in one place before you fix them.
Accessible Implementation
For inline errors, associate them with fields using aria-describedby:
<input id="email" aria-describedby="email-error" aria-invalid="true">
<div id="email-error" role="alert">Please enter a valid email</div>
For error summaries, use a landmark and live region:
<div role="alert" aria-live="assertive" tabindex="-1">
<h2>Please fix the following errors:</h2>
<ul>
<li><a href="#email">Email address is required</a></li>
<li><a href="#phone">Phone number is invalid</a></li>
</ul>
</div>
The best user experience often combines both patterns: show the summary for overview, but also display inline errors so users don't need to scroll back and forth.
Key Takeaway: Use inline errors for immediate, field-specific feedback and error summaries for form-wide validation overviews—combining both provides the most accessible experience.