DEV Community

Cover image for Why you should avoid using div when creating custom buttons
RR Joson
RR Joson

Posted on

Why you should avoid using div when creating custom buttons

Let's say you need to create a signup button with custom styling. You might try to create a div element and add your CSS and add an onClick handler. Instead of using a div element, a good practice is to use a button element instead of a div.

This is because using a button element provides built-in keyboard accessibility. Another reason why you might want to use semantic HTML for your buttons is that it is good for SEO. Search engines give more importance to keywords inside buttons compared to divs.

Top comments (0)