CSS

How to Make a Button Link to Another Page in HTML

In this tutorial, we are going to see how to make a button link to another page in HTML. There are many ways to make an HTML button that looks like a link (that is, once the user clicks on the link, the user is redirected to another page).

Pick one of the following techniques to make a link to another page using HTML button.
 

1. Add onclick event on <button> tag
<!DOCTYPE html>
<html>
   <head>
      <title>Make a Button Link to Another Page</title>
   </head>
   <body>
      <button onclick="window.location.href = 'https://stackhowto.com';"> Click here </button>
   </body>
</html>
Result
 

2. Add onclick event on <input> tag
<!DOCTYPE html>
<html>
   <head>
      <title>Make a Button Link to Another Page</title>
   </head>
   <body>
      <input type="button" onclick="window.location.href = 'https://stackhowto.com';" value="Click here"/>
   </body>
</html>
Result
 

3. Use the form’s action attribute
<!DOCTYPE html>
<html>
   <head>
      <title>Make a Button Link to Another Page</title>
   </head>
   <body>
      <form action="https://stackhowto.com">
         <button type="submit">Click here</button>
      </form>
   </body>
</html>
Result
 

4. HTML button that acts as a link using CSS
<!DOCTYPE html>
<html>
   <head>
      <title>Make a Button Link to Another Page</title>
      <style>
         .button {
            background-color: #1c87c9;
            box-shadow: 0 5px 0 #105cad;
            color: white;
            padding: 1em 1.5em;
            position: relative;
            text-decoration: none;
            display: inline-block;
        }
      </style>
   </head>
   <body>
      <a href="https://stackhowto.com" class="button">Click here</a>
   </body>
</html>
Result
Click here
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *