Home > Web Front-end > HTML Tutorial > How to set a hyperlink on an html button? Four implementation methods of html button hyperlinks

How to set a hyperlink on an html button? Four implementation methods of html button hyperlinks

不言
Release: 2018-10-09 13:54:16
Original
45865 people have browsed it

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>
Copy after login

html button hyperlinkThe effect is as follows:

How to set a hyperlink on an html button? Four implementation methods of html button hyperlinks

##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>
Copy after login

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>
Copy after login

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(&#39;连接&#39;)">
</a>
Copy after login
Instructions:


1. If you jump directly to a new page on this page, use:

2. If If you need to open a new page to jump, use:

The above is the entire content of this article, and more For more exciting content, you can pay attention to the PHP Chinese website! ! !


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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template