HTML button that sends you to another page


How can I make a button that sends me to another page that I specify? So far I have only known how to do it with the <a> tag and its href and target attributes. But I can't do it with a <button> .


You can do it like this:

<!DOCTYPE html>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>

<button onclick="location.href=''">Llévame a otro lado</button>

You do not occupy any of the a label, but thanks to location.href it indicates the address to which you want to go

Scroll to Top