How can we link a html button?
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>
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.
下一篇: 我们如何链接一个HTML按钮?