Home  >  Article  >  Web Front-end  >  Detailed explanation of the usage and function of target blank attribute in HTML a tag

Detailed explanation of the usage and function of target blank attribute in HTML a tag

藏色散人
藏色散人Original
2018-09-01 10:54:0535811browse

When making HTML pages, we often use the a tag attribute. As we all know, the a tag is used to define hyperlinks. If we are designing an HTML page and need to achieve the functional effect of clicking on a certain text or element to open one page and jump to another page, we will use the a herf tag attribute here. The herf tag is what you specify to jump to. A certain link address.

a tagThe syntax is as follows

<a href="你所要跳转的地址"></a>

So I don’t know if you have noticed that sometimes the target=_blank attribute is found in the a tag. Some novices may not be clear about this attribute. So this article will give you a detailed explanation of the specific usage and function of the target blank attribute of the HTML a tag.

The following is a simple HTML code example with the target blank attribute as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>html a标签target blank属性使用示例</title>
</head>
<body>
<a href="http://www.php.cn" target="_blank">点我看看是不是跳转到指定的PHP中文网首页</a>
</body>
</html>

You can copy and paste this code directly for local testing, the effect is as follows :

Detailed explanation of the usage and function of target blank attribute in HTML a tag

Detailed explanation of the usage and function of target blank attribute in HTML a tag

You can find that this text has been added with a hyperlink. After clicking, it successfully jumps to a new page, and everyone can find He opened a new window, and the previous page had no effect at all! So the attribute target=_blank means to open the hyperlink in a new window! Through this attribute, we can more conveniently view various jump pages. Don't worry about previous pages being overwritten.

If we do not set the target blank attribute, we will find that a new link is opened in the current window and the previous page will disappear.

We also need to pay special attention here:

The target blank attribute in the a tag must be together with herf to be effective!

So the above is the specific content of this article on the use and function of the target blank attribute in HTML. Hope it helps those in need!

The above is the detailed content of Detailed explanation of the usage and function of target blank attribute in HTML a tag. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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