Home  >  Article  >  Web Front-end  >  What is the usage of target in css3

What is the usage of target in css3

WBOY
WBOYOriginal
2022-03-17 17:13:073690browse

Usage: 1. The ":target" selector is used to select the currently active target element, and the syntax is ":target{style}"; 2. The target attribute is used to set the style of the hyperlink, and the syntax is "target :target-name target-new target-position".

What is the usage of target in css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

What is the usage of target in css3

: The target selector can be used to select the currently active target element.

URL with an anchor name # followed by it points to a specific element within the document. The linked element is the target element.

The example is as follows:

<html>
<head>
<style>
:target
{
border: 2px solid #D4D4D4;
background-color: #e5eecc;
}
</style>
</head>
<body>
<h1>这是标题</h1>
<p><a href="#news1">跳转至内容 1</a></p>
<p><a href="#news2">跳转至内容 2</a></p>
<p>请点击上面的链接,:target 选择器会突出显示当前活动的 HTML 锚。</p>
<p id="news1"><b>内容 1...</b></p>
<p id="news2"><b>内容 2...</b></p>
<p><b>注释:</b> Internet Explorer 8 以及更早的版本不支持 :target 选择器。</p>
</body>
</html>

Output result:

What is the usage of target in css3

The target attribute is a shorthand attribute setting target-name, target -new, and target-position attributes.

The target attribute is not supported by any mainstream browser.

Syntax

target: target-name target-new target-position;

target-name specifies where to open the hyperlink (target destination).

target-new specifies that the hyperlink should be opened in a new window or a new tab in an existing window.

target-position specifies where to place the new destination link.

(Learning video sharing: css video tutorial)

The above is the detailed content of What is the usage of target in css3. 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