Design comparison
SolutionDesign
Community feedback
- @grace-snowPosted 18 days ago
This challenge is a great one to learn and practice how to make forms accessible. There are some problems in your solution so far, and some potential improvements.
- All inputs must have a label. In some of these instances you've included a label element but not linked it to the input properly with
for
. - The clear all button should be inside the form because it is the reset for the form. The heading can move inside it too.
- I would make all of those elements you have with the
spacer
classaria-hidden="true"
and instead include that information as visually-hidden (sr-only) text in a span inside the field label. This will ensure that screen reader users get the same information at an appropriate time, just as anyone else would. - When linking inputs and error messages, there are more accessible patterns than you are using currently. The requirements are for all users to (a) know an error has occurred and (b) have that error linked programmatically to its input. I recommend you wrap each error in an extra element. Give each a unique ID and an
aria-live="assertive"
. Then addaria-describedby
on each input referencing the ID of the error wrapper. - The form should have a
novalidate
attribute on it because you're using custom validation. - I'm not sure why you're not using the required attribute? It's fine to use aria-required but that's only usually used when using non-native HTML elements (i.e. it's used on generic elements that have had their role changed).
- On submission, if an error is present, move focus to the first field which has the error. This solves multiple problems because it means the field and error will scroll into view as well as ensuring people are ready to correct their error.
- It is essential to include clearly visible focus-visible styles on all interactive elements. As a keyboard user I need to know where I am on a page. But you have set outline to 0 and not added any custom focus-visible styling on the radios so I'm immediately lost.
- "Mortgage type" is not a label element. That's invalid. Why not use a
fieldset
andlegend
for this instead ofrole
andaria-labelledby
? - The results container should be an
aria-live
not just the numbers inside it. For an aria-live region to function it must already be registered as one (i.e. notdisplay: none
at the start). And on the first content change all of that results information should be announced to screen readers. - The results card should be a description list or table. The text and numbers are key value pairs that are designed to be understood as a pair.
- General pointer: Try not to include empty divs with classes for styling purposes. You actually want a border for that grey line, or pseudo element, not a whole extra div.
- Why is there some duplicate content in there with the class "display-switch"? You shouldn't need that.
- Don't forget to remove console logs from your code.
Marked as helpful1 - All inputs must have a label. In some of these instances you've included a label element but not linked it to the input properly with
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord