DEV Community

Discussion on: Dark mode toggle animation using CSS !

Collapse
 
robole profile image
Rob OLeary • Edited

Hi Murtuza,

I have one suggestion. For accessibility, it would be better if you use button instead of div for the container. A button gets focus for keyboard users and is announced by screen readers as something actionable. When there is no text inside, you can add an aria-label attribute.

Something like this:

<button class="container" aria-label="Dark mode toggle">
   <!-- existing code -->
</button.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
murtuzaalisurti profile image
Murtuzaali Surti

Thanks for mentioning that! I will take care of that.