What is the usage of target in css3

WBOY
Release: 2022-03-17 17:13:07
Original
3787 people have browsed it

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

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

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!

Related labels:
css
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