0

I would like to create an HTML button that acts like a link. So, when you click the button, it redirects to a other html webpage we want.

Currently i am doing,

 <form
 action="path">
 <button
 type="submit">
 login
 </submit>
 </form>
  • http://stackoverflow.com/questions/2906582/how-to-create-an-html-button-that-acts-like-a-link – tech2017 May 15 '17 at 14:41
  • 2
    _“I would like it to be as accessible as possible”_ - then use a link. You do not want a button to work as a link - you want a link to _look_ like a button. So format it accordingly. – CBroe May 15 '17 at 14:42
  • 3
    Possible duplicate of [How to create an HTML button that acts like a link?](http://stackoverflow.com/questions/2906582/how-to-create-an-html-button-that-acts-like-a-link) – blackandorangecat May 15 '17 at 14:57

2 Answers2

0

Always use https:// when linking a HTML button especially. Let me give you a few snippets to prove my answer:

<a href="https://stackoverflow.com">Stack Overflow</a>

<a href="https://stackoverflow.com/questions/ask">Ask a Question on Stack Overflow</a>

If you want a hyperlink, you can use this code (I don't think regular buttons work on this website):

<button> <a href="https://stackoverflow.com">Stack Overflow Button</a></button>

Hope this helped with your code!

-1

There is already a very similar question to this (How to create an HTML button that acts like a link?).

Here are two other ways to do it - although crude and not valid.

<button><a href="http://www.google.com">Button Text</a></button>

OR

<a href="http://www.google.com"><button>Button Text</button></a>

OR

<form style="display: inline" action="http://www.google.com" method="get"> <button>Visit Website</button> </form>

EDIT: As Pete pointed out, while the two methods with <a> and <button> work, the HTML is not valid by W3C standards. The form method is valid.

Community
  • 1
  • 1
blackandorangecat
  • 1,246
  • 5
  • 18
  • 37