There are several methods to create an HTML button that acts as a link. Some of them are discussed below:
Note: Adding basic CSS property to the button in every method to make button looks better.
- Using onclick Event: The onclick event attribute works when the user click on the button. When mouse clicked on the button then the button acts like a link and redirect page into the given location.
<!DOCTYPE html>
< html >
< head >
< title >
Create an HTML button that
acts like a link
</ title >
< style >
.GFG {
background-color: white;
border: 2px solid black;
color: green;
padding: 5px 10px;
text-align: center;
display: inline-block;
font-size: 20px;
margin: 10px 30px;
cursor: pointer;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< button class = "GFG"
Click Here
</ button >
</ body >
</ html >
|
- Using button tag inside <a> tag: This method create a button inside anchor tag. The anchor tag redirect the web page into the given location.
<!DOCTYPE html>
< html >
< head >
< title >
Create an HTML button that
acts like a link
</ title >
< style >
.GFG {
background-color: white;
border: 2px solid black;
color: green;
padding: 5px 10px;
text-align: center;
display: inline-block;
font-size: 20px;
margin: 10px 30px;
cursor: pointer;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< button class = "GFG" >
Click Here
</ button >
</ a >
</ body >
</ html >
|
- Adding styles as button to a link: This method create a simple anchor tag link and then apply some CSS property to makes it like a button.
<!DOCTYPE html>
< html >
< head >
< title >
Create an HTML button that
acts like a link
</ title >
< style >
.GFG {
background-color: white;
border: 2px solid black;
color: green;
padding: 5px 10px;
text-align: center;
display: inline-block;
font-size: 20px;
margin: 10px 30px;
cursor: pointer;
text-decoration:none;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
Click here
</ a >
</ body >
</ html >
|
- Using form tags: This method uses form tag and button tag. When button is clicked then the form action attribute is called and web page redirect into the given location.
<!DOCTYPE html>
< html >
< head >
< title >
Create an HTML button that
acts like a link
</ title >
< style >
.gfg {
background-color: white;
border: 2px solid black;
color: green;
padding: 5px 10px;
text-align: center;
display: inline-block;
font-size: 20px;
margin: 10px 30px;
cursor: pointer;
}
</ style >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< button class = "gfg" type = "submit" >
Click Here
</ button >
</ form >
</ body >
</ html >
|
Note: The output will be same for every method.
Output:
- Before clicking the button:

- After clicking the button:

HTML is the foundation of webpages, is used for webpage development by structuring websites and web apps.You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
29 Jul, 2021
Like Article
Save Article