Buttons should be written using the <button>
html tag. However, if a button is an <a>
tag styled with the .btn
class and has in-page functionality (such as toggling elements), the role
attribute should be set to “button” and the tabindex
attribute should be set to “0.” Refer to the best practices illustrated in the MDN documentation for the “button” role.
If the button is a <button>
element and appears within a <form>
tag, the type
attribute should be explicitly set to “button,” “reset,” or “submit.” By default (without the type attribute) <button>
elements are set to the “submit” type.
The base button class, .btn
, is extended with additional button classes described below.