DEV Community

Discussion on: Pure CSS checkboxes with one element

Collapse
 
grahamthedev profile image
GrahamTheDev • Edited

Why do I always have to be the bad guy?

Sorry @posandu at 13 years old you are doing amazing, Temani was mean summoning me!

However I won't "pull my punches" due to your age, none of these are criticisms of your work, just things you may not know to look for yet 😋

So here a few things that mean this isn't fully accessible (yet):-

  1. Using colour alone to indicate check state is not enough, you need to account for people who have colour blindness (with that being said I think the difference between the two states would be significant enough but it is still a good practice).
  2. For people with a cognitive impairment it may not be evident that blue means checked. I would suggest adding an icon that changes depending on state or some other method that makes sense (as when all of them are unchecked there is no point of reference for state)
  3. On iphone you get a gigantic tick mark that interferes with the legibility of text (but ironically would work for fixing the above issue). I think this is because you didn't prefix appearance: none for iPhone as I believe it should work when prefixed. (try prefixing it -> -webkit-appearance: none and see if that fixes it)
  4. You need a <label> for your checkbox that is properly associated (preferably with for="idOfCheckBox" as it is more robust than wrapping the input in the <label>) so that people who use assistive tech know what the control is for. The content attribute is not picked up by most screen readers.
  5. In the "unchecked" state there is not sufficient contrast with the background, it needs to be a minimum of 3:1 (add a border maybe?)
  6. Not a fail on WCAG as the animation is short but I would suggest adding prefers-reduced-motion media queries to turn off animations for people who request it, generally people with vestibular orders, anxiety disorders etc. as animation can be unsettling or distracting.
  7. Your text doesn't scale with font size changes. Use rem and em units for font sizes so if a user sets their browser size to large the font scales according.
  8. Your text needs to be larger or you need to darken the blue. At the moment the contrast is only 3.2:1 and the text does not qualify as "large text". It would need to be bold and 18px equivalent (about 1.1rem) or normal weight and 24px equivalent (1.5rem) at the current contrast levels.

That is all I can spot for now! If you need any help understanding any of those points or how to solve any of them just let me know.

And although that looks like a lot of things, most of them are quick fixes and other than the lack of a label this is better than most examples I have seen!

A lot of examples aren't usable with a keyboard whereas yours is so, great job!

For checking colour contrast you can use the WebAim colour contrast checker

Collapse
 
afif profile image
Temani Afif

and the community have a lost a young developer ...

🤣

Thread Thread
 
grahamthedev profile image
GrahamTheDev

Baptism of fire, if they manage to implement all of those things they are already better than most senior devs and will be a mega star developer!

Thread Thread
 
afif profile image
Temani Afif

they are already better than most senior devs --> hmm, why I have a strange feeling that I am concerned by this 🤔🤔
XX: no, no your are not, keep calm ... Xanti is on vacation now ...

Thread Thread
 
grahamthedev profile image
GrahamTheDev

🤣 for once it was an innocent comment, I am not always mean you know!

Thread Thread
 
posandu profile image
Posandu • Edited

Thank you so much @afif and @inhuofficial . (For the tips and etc)

Collapse
 
posandu profile image
Posandu • Edited

Thank you very much @inhuofficial I will update this post for your accessibility guidelines.