simedr
simedr

Reputation: 11

How do I use a button to navigate to a website in HTML5?

So I want to use a button to navigate to another website. I assume it has something with the "a href" tag to do. Thanks in advance! //Simon

Upvotes: 1

Views: 1071

Answers (3)

Musa
Musa

Reputation: 97717

Here is a method without Css or javascript

<form action="http://example.com"><input type="submit" value="Go somewhere"></form>

http://jsfiddle.net/2ccaK/

Upvotes: 1

Gui Imamura
Gui Imamura

Reputation: 722

Assuming that you specifically want a button, you can set a url to location.href:

<button onclick="location.href = 'https://stackoverflow.com'">Visit us!!</button>

Btw, try googling stuff first.

Upvotes: 0

Jamie Taylor
Jamie Taylor

Reputation: 4775

If you really want a button and not just an <a> tag

<button onclick="window.location.href='http://example.com'">Navigate!</button>

demo

Upvotes: 2

Related Questions