What element should I use to show validation开发者_StackOverflow中文版 messages (errors) to the user? Which one is more semantic in HTML5?
You could consider adding an ARIA role of 'alert' or 'status'. I don't think that semantically any of the HTML elements is any better than <div class="error">
I typically would use a div
with an error
or notice
class to show errors.
I would use javascript to show a javascript error box containing the erro(s).
EDIT: For server side validation we use a <div>
that gets filled after an ajax call.
精彩评论