How do you create a button that is a link? | SoloLearn: Learn to code for FREE!

+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.

1/29/2020 10:31:19 PM

Coͥdeͣrͫ

22 Answers

New Answer

+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>

+17

Put the <a> tag inside of the button tag.

+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>

+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.

+9

<button onclick="window.location.href = 'https://www.sololearn.com';">Click Here</button> This is another way.

+9

Here is another way: <form action="http://google.com"> <input type="submit" value="Go to Google" /> </form>

+7

Rei , what is the file? Is it a picture, or a link?

+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

+4

You can create button using <a> tag and CSS. And this will look more beautiful

+4

<a href="url"> <input type="button" value="hyperlink button"> </a>

+3

You can use <a> tag inside button tag or u can use <form action=‘file u want’> <button type=‘submit’></button>

+3

its like ‘index.html’ or any other file name in the same dir

+2

Ok. Thanks for the clarification.

+2

<!DOCTYPE html> <html> <body> <button> <a href="paste link here"></a></button> </body> </html>

+2

<a> tag inside the button tag is not good way. <a><button>Click</button></a>

+2

<button><a href="link"></a></button> con una imagen sería: <a href="link"><img></a>

+2

Anchor tag is not the only way. You can use Canvas, CSS, or JS to create one also.

+1

<button> <a href="enter ur link"></a></button>

+1

<a href="www.rickyberwick.com"></a>

+1

https://code.sololearn.com/WeK4RZnF6gUN/?ref=app