首页 文章

我们如何链接一个HTML按钮?

提问于
浏览
0

我想创建一个像按钮一样的HTML按钮 . 因此,当您单击该按钮时,它会重定向到我们想要的其他html网页 .

目前我在做,

<form
 action="path">
 <button
 type="submit">
 login
 </submit>
 </form>

1 回答

  • -1

    已经有一个非常类似的问题(How to create an HTML button that acts like a link?) .

    以下是另外两种方法 - 虽然粗糙但无效 .

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

    要么

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

    要么

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

相关问题