# Should a clickable thing be a button or a div with onclick

Source: https://coursesweb.net/forum/t/should-a-clickable-thing-be-a-button-or-a-div-with-onclick/
Site: CoursesWeb Forum, category HTML Structure and Semantics
Published: 2026-11-27. Updated: 2026-11-27. Replies: 1.

## Question by Noor A., 2026-11-27

I am a designer moving into front end code, and I am rebuilding a pricing toggle from a design file. The developer before me wrote it like this:

```html
<div class="toggle" onclick="switchPlan()">Yearly</div>
```

It looks right and works with a mouse. But when I test with only the keyboard, Tab skips straight past it, and Enter does nothing. Our screen reader test (VoiceOver) reads it as plain text "Yearly" with no hint that it does anything.

I could add tabindex="0" and a keydown listener, but that feels like rebuilding something that should already exist. Is there ever a good reason to use a div with onclick instead of a real button? And if I switch to `<button>`, how do I get rid of the default grey browser styling without breaking anything?

## Reply 1 by Dov L., 2026-11-27

In 2011 we made everything a div or an anchor with href="#" and styled it. Nobody tested with a keyboard. So I can tell you why the old code looks like that, not that it was right.

---
Cite as: CoursesWeb Forum, "Should a clickable thing be a button or a div with onclick", https://coursesweb.net/forum/t/should-a-clickable-thing-be-a-button-or-a-div-with-onclick/, accessed 2026-11-27.
