In html, sometimes you may need to set a button hyperlink for good looks and convenience. So how to set a hyperlink for an html button? Next, in this article, we will take a look at the four implementation methods of html button hyperlinks. Friends in need can refer to them.
Method 1 for setting hyperlinks on html buttons: Using the method of combining hyperlinks with buttons
html button hyperlinksConnectionThe code is as follows:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <a href="http://www.php.cn/"> <input type=button value="php中文网" > </a> </body> </html>
html button hyperlinkThe effect is as follows:
##Description: href attribute of tag URL used to specify the target of a hyperlink.Method 2 for html button to set hyperlink: Use link and css style settings to set the hyperlink into the shape of button
html button hyperlink code is as follows :<!DOCTYPE html> <html> <head> <title></title> <style type="text/css"> a.button { -webkit-appearance: button; -moz-appearance: button; appearance: button; text-decoration: none; color: initial; } </style> </head> <body> <a href="http://www.php.cn" class="button">php中文网</a> </body> </html>
Method 3 for setting hyperlinks on html buttons: Use form form to set html button hyperlinks
html button hyperlink code is as follows:<!DOCTYPE html> <html> <head> <title></title> </head> <body> <form method="get" action="http://www.php.cn/"> <button type="submit">php中文网</button> </form> </body> </html>
Method 4 for setting hyperlinks on html buttons: Use the window.location.href method
Complete writing method:<a href="链接"> <input type=button onclick="window.location.href('连接')"> </a>
2. If If you need to open a new page to jump, use:
The above is the detailed content of How to set a hyperlink on an html button? Four implementation methods of html button hyperlinks. For more information, please follow other related articles on the PHP Chinese website!