This content originally appeared on Manuel Matuzović - Web development blog and was authored by Manuel Matuzović
…if the classname of an element contains “button” or “btn“, the element is in fact a <button>
.
<div class="edit-button">
Edit
</div>
More accessible alternative:
<button class="edit-button">
Edit
</button>
Explanation
A <button>
button has several advantages over the <div>
button:
- It conveys the correct “button” role
- It’s accessible via keyboard
- If a click event is attached, it provides keydown and keyup events automatically
My blog doesn't support comments yet, but you can reply via blog@matuzo.at.
This content originally appeared on Manuel Matuzović - Web development blog and was authored by Manuel Matuzović

Manuel Matuzović | Sciencx (2023-04-17T09:46:54+00:00) btn class on a div. Retrieved from https://www.scien.cx/2023/04/17/btn-class-on-a-div/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.