Ask coding questions

← Back to all posts
Do you know how to code buttons
ZakMcCall

Thx in advance. I need this for a light mode and a dark mode

Voters
ZakMcCall
Comments
hotnewtop
tussiez

Here's a button:

HTML

CSS

JavaScript: (toggles light/dark mode)

OldWizard209

The simplest way to create a button in HTML, would be using an anchor tag, but change its look using CSS. So here would be the HTML:

Embed this HTML in a HTML boilerplate.

And here is the CSS:

This is the fastest way to make a working button. But this is not enough. To make an actual button use a <button> tag.

Bookie0

If you want a light and dark theme, you can use CSS variables with different "themes", and you can use JS to toggle between them.

Check this out for more

And for buttons just use the <button></button> tag.

Learn more here

Good luck! :D

Coder100

well buttons are super easy, they are HTML!

now for the hard part, making them interactive requires js.