How to use attribute selectors and pseudo-class selectors

php中世界最好的语言
Release: 2017-11-24 10:00:43
Original
2369 people have browsed it

Today we will tell you about the usage and related connections and differences betweenAttribute Selectorand PseudoClass Selector. Here is a small example.

Attribute selector:

[attr~="value"] Word Word Space Word Word must be valid

[attr|="value"] Value starts with or value - Word

Note:

It is difficult to use rulesexpressionsto identify selected elements when selecting attributes, which is more efficient

Pseudo-class Selector:

: before

: after

:lang(val) val/val-word

:nth-child(n) nfrom Starting from 1, odd base and even even number

:nth-of-type(n) selector matches every element that is the Nth child element of a specific type of the parent element.

    无标题文档  

aaa

aaa

aaa

aaa

Css部分: @charset "utf-8"; /* CSS Document */ /* p:before{ content:"ccc"; } p:lang(en){ border:1px solid #ff0000; } p:nth-child(even){ background:#F00; } */ p:nth-of-type(3){ /* p标记的父元素 下的 第3个p元素*/ background:#F00; }
Copy after login

Related Read:

How to hide content that overflows a DIV

What are the techniques for CSS layout

Font styles in CSS How to set up

The above is the detailed content of How to use attribute selectors and pseudo-class selectors. For more information, please follow other related articles on the PHP Chinese website!

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