- How to Make a HTML Link Button
- Community Q&A
- 5 Ways To Create HTML Button Links (Simple Examples)
- QUICK SLIDES
- TABLE OF CONTENTS
- DOWNLOAD & NOTES
- QUICK NOTES
- EXAMPLE CODE DOWNLOAD
- BUTTON LINKS
- METHOD 1) JAVASCRIPT REDIRECT
- METHOD 2) SUBMIT FORM
- METHOD 3) FORM ACTION
- METHOD 4) TURN LINK INTO BUTTON WITH CSS
- METHOD 5) WRAP BUTTON INSIDE LINK
- USEFUL BITS & LINKS
- WHICH IS THE BEST METHOD?
- LINKS & REFERENCES
- YOUTUBE TUTORIAL
- INFOGRAPHIC CHEAT SHEET
- THE END
- How to Create an HTML Button That Acts Like a Link
- How to Create an HTML Button Using the Button Tag in an A Tag
- How To Turn a Link Into a Button with CSS
- How to Put a Button inside a Form Using HTML
How to Make a HTML Link Button
wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 14 people, some anonymous, worked to edit and improve it over time.
The wikiHow Tech Team also followed the article’s instructions and verified that they work.
This article has been viewed 136,489 times.
This article will show you how to make a HTML link button. It behaves similar to a normal hyperlink, but instead, it’s a button.
Add the following code to the area where you want the button to appear:
Change the link. Currently the code points to wikiHow’s homepage. Replace it with the URL of the page you wish to link to.
Change the button text. Currently the button says «Homepage». You can change it to what ever you would like it to say.
Test out the link. Left click the link to make sure it works. If it works, then you’re done. If the button does not, you should check your code for mistakes.
Community Q&A
Follow the steps in the article, but change the text of the button and the link to whatever you need.
Thanks! We’re glad this was helpful.
Thank you for your feedback.
As a small thank you, we’d like to offer you a $30 gift card (valid at GoNift.com). Use it to try out great new products and services nationwide without paying full price—wine, food delivery, clothing and more. Enjoy! Claim Your Gift If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow
Thanks! We’re glad this was helpful.
Thank you for your feedback.
As a small thank you, we’d like to offer you a $30 gift card (valid at GoNift.com). Use it to try out great new products and services nationwide without paying full price—wine, food delivery, clothing and more. Enjoy! Claim Your Gift If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow
No, a button can only do one job. Think of a volume switch on a phone. You can’t get that button to turn the volume up, and turn the phone on, and make a call, all at once. The button can only have one job. Add more buttons as needed.
Thanks! We’re glad this was helpful.
Thank you for your feedback.
As a small thank you, we’d like to offer you a $30 gift card (valid at GoNift.com). Use it to try out great new products and services nationwide without paying full price—wine, food delivery, clothing and more. Enjoy! Claim Your Gift If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow
5 Ways To Create HTML Button Links (Simple Examples)
Welcome to a quick tutorial on how to create HTML button links. Text links work great, but they sure are not catchy enough. Also on mobile devices, one with fat fingers may have a little trouble with tapping that small text link.
But there are actually several other ways to do so – Read on to find out!
ⓘ I have included a zip file with all the example source code at the start of this tutorial, so you don’t have to copy-paste everything… Or if you just want to dive straight in.
QUICK SLIDES
TABLE OF CONTENTS
DOWNLOAD & NOTES
Firstly, here is the download link to the example code as promised.
QUICK NOTES
If you spot a bug, feel free to comment below. I try to answer short questions too, but it is one person versus the entire world… If you need answers urgently, please check out my list of websites to get help with programming .
EXAMPLE CODE DOWNLOAD
Click here to download the source code, I have released it under the MIT license, so feel free to build on top of it or use it in your own project.
BUTTON LINKS
All right, let us now get into the various ways to create a “button link” in HTML.
METHOD 1) JAVASCRIPT REDIRECT
- The onclick property is used to specify what to do when the button is clicked.
- location = ‘URL’ will set where to redirect to when the button is clicked.
P.S. You will notice that some other tutorials use location.href = ‘URL’ instead. That is not wrong and is the “old fashion” way of redirecting. Both will still work, location is a synonym of location.href .
METHOD 2) SUBMIT FORM
Who says that we can’t use forms in creative ways? The above will submit an empty form, which effectively acts just like a link. A couple of short notes for the absolute beginners:
- Change the action=»URL» to redirect the user to where you want.
- We can also add a target=»_blank» to open in a new tab. Otherwise if not defined, it will default to target=»_self» and open in the same window.
- Take note that we are using here instead of – Submit will process the form when clicked, a button will not.
METHOD 3) FORM ACTION
The formaction is a property added in HTML5, and it is actually used to submit a form to an alternative URL. In the case of “button to link”, we can use it as a convenience to create multiple links in a single form.
METHOD 4) TURN LINK INTO BUTTON WITH CSS
The beauty of HTML and CSS – We can pretty much customize almost every element. Yes, we can even customize a link to look exactly like a button… But it is still essentially a link.
METHOD 5) WRAP BUTTON INSIDE LINK
It is not a secret, we can wrap images in links. So yes, we can have the best of both worlds – Wrap buttons in links.
USEFUL BITS & LINKS
That’s all for this tutorial, and here is a small section on some extras and links that may be useful to you.
WHICH IS THE BEST METHOD?
Personally, I will either wrap the button in a link or use CSS to turn the link into a button. The main reasons are actually the ease of implementation, and for the purpose of search engine optimization (SEO). This might be a slightly advanced topic, but in short, we want to help search engines to find relevant links on the webpage as easily as possible.
For example, if we have a page about how to play the piano, we will want to include relevant links to other relevant piano pages… But here’s the problem – Search engines won’t necessarily follow all the Javascripts and forms to see where they lead to. So stick with using the traditional as much as possible.
LINKS & REFERENCES
YOUTUBE TUTORIAL
INFOGRAPHIC CHEAT SHEET
THE END
Thank you for reading, and we have come to the end of this guide. I hope that it has helped you with your project, and if you want to share anything with this guide, please feel free to comment below. Good luck and happy coding!
How to Create an HTML Button That Acts Like a Link
Sometimes you may want to use a button to link to another page or website rather than to submit a form or something like that. This is fairly simple to do and can be achieved in several ways.
How to Create an HTML Button Using the Button Tag in an A Tag
One way is to simply wrap your tag in an tag:
This transforms your entire button into a link.
How To Turn a Link Into a Button with CSS
A second option is to create your link as you normally would with your tag and then style it via CSS:
Once you’ve created your link, you can the use CSS to make it look like a button. For instance, you could add a border, a background color, some styles for when the user is hovering the link.
How to Put a Button inside a Form Using HTML
Another way to add a button is to wrap an input inside form tags. Specify the desired target URL in the form action attribute.
I hope you’ve found tutorial helpful. Happy coding.
If this article was helpful, tweet it .
Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started
freeCodeCamp is a donor-supported tax-exempt 501(c)(3) charity organization (United States Federal Tax Identification Number: 82-0779546)
Our mission: to help people learn to code for free. We accomplish this by creating thousands of videos, articles, and interactive coding lessons — all freely available to the public. We also have thousands of freeCodeCamp study groups around the world.
Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff.