-
Notifications
You must be signed in to change notification settings - Fork 477
Description
Describe the issue
The usage of button for closing modals makes a lot more sense than a.
- from w3:
The
buttonelement should be used for any interaction that performs an action on the current page. Theaelement should be used for any interaction that navigates to another view.
- from UX: Links only respond to
Enterkey presses. Buttons respond to bothEnterandSpace. - Links need to have an
hrefattribute in order to be accessible. This forces the usage ofhref=#, which can confuse screen readers and will in fact perform the scroll animation unless theonclickhandler returnsfalse, which further increases verbosity.
Solutions
One solution would be to recommend button as a way to close modals, and properly style any button with class=close (or rel=prev even though it is not valid on buttons, and also a non-standard way to describe dialog closing actions).
Extending the previous solution for classless pico, we can use <form method=dialog> HTML element, which is a non-Javascript solution to closing dialogs. Alternatively if the button is already in a form, we can use <button formmethod=dialog>.
Here is a demo of the extended solution on CodePen.
If you agree on the issue, let me know which solution you like best and I can start working on a PR!