Home>Article>Web Front-end> What is the css target pseudo-class?

What is the css target pseudo-class?

青灯夜游
青灯夜游 Original
2020-11-13 14:17:12 2592browse

In css, the target pseudo-class is ":target", and the syntax format is "E:target{css style}", which means that all elements matching E are selected, and the matching elements are pointed to by the relevant URL; this selection The selector is a dynamic selector, and the style effect can only be effective when there is a URL pointing to the matching element.

What is the css target pseudo-class?

(Recommended tutorial:CSS video tutorial)

In css, the target pseudo-class selector is ": target" is one of the many dynamic pseudo-class selectors in CSS3, used to match the element pointed to by the anchor and highlight the active HTML anchor.

Syntax:

E:target{css样式}

means to select all elements matching E, and the matching elements are pointed to by the relevant URL. This selector is a dynamic selector, and the style effect will only be effective when there is a URL pointing to the matching element. The process of "

:target" taking effect in CSS is as follows: when the hash in the browser address (the part after the # sign in the address) matches the ID specified by the :target pseudo-selector, it The style will take effect on this ID element.

Example:

     

点击下面的链接,你会看到浏览器地址是hash值的变化,以及相应链接的CSS样式变化!这是:target伪选择器在起作用。

Heading 1 |
Heading 2 |

Anchor 1

Anchor 2

Rendering:

What is the css target pseudo-class?

Note: IE8 and below This version of the browser does not support the E:target selector

For more programming-related knowledge, please visit:Programming Learning Website!!

The above is the detailed content of What is the css target pseudo-class?. 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