DEV Community

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

Posted on

3 1

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more