+ 12

How do you create a button that is a link?

I looked, but didn't see any answers. How do you create a button that serves the purpose of the <a> tag, but is a button.

29th Jan 2020, 10:31 PM
Coͥdeͣrͫ
Coͥdeͣrͫ - avatar
23 ответов
+ 22
You put the <a> tag inside of the button tag. You could also if you want different text size, put a tag such as <h3> inside of the <a> tag also. The example code: <button><a href="#LinkGoesHere"></a></button>
29th Jan 2020, 10:39 PM
Green Ghost
Green Ghost - avatar
+ 17
Put the <a> tag inside of the button tag.
29th Jan 2020, 10:34 PM
Bob Brown
Bob Brown - avatar
+ 14
To add onto Green Ghost, there is two types of links. One that heads to somewhere else in the code, or one that heads to another link/source. On top, you can have different colors using CSS. If you want it to be centered, add <center> tags like this: <center><button><a></a></button></center>
29th Jan 2020, 10:48 PM
Coding Person
Coding Person - avatar
+ 10
By using HTML... Real Answer: You can put tags inside of tags in HTML, so you would put the <a> tag inside of the <button> tag.
29th Jan 2020, 10:58 PM
itsjustmeagain Course
itsjustmeagain Course - avatar
+ 9
<button onclick="window.location.href = 'https://www.sololearn.com';">Click Here</button> This is another way.
29th Jan 2020, 11:37 PM
Blue Blitz Coder
Blue Blitz Coder - avatar
+ 9
Here is another way: <form action="http://google.com"> <input type="submit" value="Go to Google" /> </form>
30th Jan 2020, 9:24 PM
HTML Master
HTML Master - avatar
+ 7
Rei , what is the file? Is it a picture, or a link?
29th Jan 2020, 10:50 PM
Coͥdeͣrͫ
Coͥdeͣrͫ - avatar
+ 5
<html> <body> <button> <a href="http://www.google.com></a>Assumed link for the explanation </button> </body> </html> i hope this answers your question
29th Jan 2020, 11:59 PM
Omolade Akinwumi
Omolade Akinwumi - avatar
+ 4
You can create button using <a> tag and CSS. And this will look more beautiful
30th Jan 2020, 6:51 PM
Faisal Ur Rehman
Faisal Ur Rehman - avatar
+ 4
<a href="url"> <input type="button" value="hyperlink button"> </a>
31st Jan 2020, 5:38 AM
Leena
+ 3
You can use <a> tag inside button tag or u can use <form action=‘file u want’> <button type=‘submit’></button>
29th Jan 2020, 10:49 PM
Rei
Rei - avatar
+ 3
its like ‘index.html’ or any other file name in the same dir
29th Jan 2020, 10:52 PM
Rei
Rei - avatar
+ 2
Ok. Thanks for the clarification.
29th Jan 2020, 10:52 PM
Coͥdeͣrͫ
Coͥdeͣrͫ - avatar
+ 2
<!DOCTYPE html> <html> <body> <button> <a href="paste link here"></a></button> </body> </html>
30th Jan 2020, 8:35 AM
ISTIAQUE ZAMAN
ISTIAQUE ZAMAN - avatar
+ 2
<a> tag inside the button tag is not good way. <a><button>Click</button></a>
31st Jan 2020, 9:45 AM
Ranjith Kumar
Ranjith Kumar - avatar
+ 2
<button><a href="link"></a></button> con una imagen sería: <a href="link"><img></a>
31st Jan 2020, 9:11 PM
Nabï ⚽
Nabï ⚽ - avatar
+ 2
Anchor tag is not the only way. You can use Canvas, CSS, or JS to create one also.
31st Jan 2020, 9:22 PM
Regulation
Regulation - avatar
+ 1
<button> <a href="enter ur link"></a></button>
30th Jan 2020, 9:53 AM
sai charan
sai charan - avatar
+ 1
<a href="www.rickyberwick.com"></a>
31st Jan 2020, 4:39 AM
Carl Wheezer
Carl Wheezer - avatar
31st Jan 2020, 12:35 PM
Faisal Ur Rehman
Faisal Ur Rehman - avatar