Skip to content
← Back to Community
How do I make a button act as a link in HTML, JS, CSS?
Profile icon
Extreme1125

I'm working on a website for my class I was wanting to make buttons that act as a link.

How do I do this?

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
marisoldrodrigu
Profile icon
Extreme1125
Comments
hotnewtop
Profile icon
Coder100

put a link around it...

<a href="/second.html"><button>Click me!</button></a>

Or, use JS:

<button onclick="location.href = '/second.html';">Click me!</button>

Or, just use a link and style it like a button smh

<a href="/second.html">Click me!</a>
a { border: 1px solid black; color: black; background: gray; }
Profile icon
Leroy01010
<button onclick='window.location.href = "www.testfiletestfile.com"'> WEEK 1 </button>

replace test file with the link you want it to go on

press the tick if it helps

Profile icon
gibbsfreenergy

Good question! Here is how you can:

Link To Your Website

This is the code, it disguises the Link under a text making it a button.
Hope this helps and have a great day!

Profile icon
EpicGamer007