After the birth of HTML in the early 1990s, CSS was born at the end of 1996. CSS is specifically designed to define the basic attributes of web pages. So in CSS3, what are the commonly used selectors? Let me introduce it to you today.
The birth of HTML in the early 1990s
At the end of 1996, the first version of CSS was born
May 1998 CSS2 was officially released
2004 CSS2 .1 Release
Release of CSS3 2002 2003 2004 2005 2007 2009 2010
Modular development
CSS1 defines the basic attributes of the web page:
font , color, Basic selector, etc.
CSS2 adds advanced functions based on CSS1
floating and positioning, advanced selector, etc. (sub-selector, relative Neighbor selector, Universal selector)
CSS3 follows modular development. The release time is not a point in time, but a period of time.
Universal selector: * Select all elements
Select child elements:> Select direct descendants of elements
Adjacent sibling selectors: + Selects the first element immediately after the target element
Ordinary sibling selector: ~ Selects all sibling elements immediately following it
:nth-child Selects the specified index Child element at
nth-child(n) nth child element under parent element
nth-child(odd) odd-numbered child element
nth-child(even ) Even child element
:nth-last-child(n) The nth child element from the bottom
:nth-of-type(n) The nth child of the specified type under the parent element Element
:nth-last-of-type The penultimate n-th child element of the specified type under the parent element
:first-child Selects the first child element under the parent element
:last-child selects the last child element under the parent element
:only-child selects the only child element under the parent element
:only-of-type selects the parent element The only child element of the specified type under
:root selects the root directory of the document and returns the html
E[attr] attribute name, not sure about the specific attribute value
E[attr ="value"] specifies the attribute name, and specifies its corresponding attribute value
E[attr ~="value"] specifies the attribute name, which has multiple attribute values separated by spaces and contains the value
E[attr ^= "value"] specifies the attribute name, the attribute value starts with value
E[attr $="value"] specifies the attribute name, and the attribute value ends with value
E[attr *="value"] specifies the attribute name, and the attribute value contains value
E[attr |= "value"] specifies the attribute name, and the attribute value starts with value-
UI PseudoClass selector:
:enabled Select the enabled state element
:disabled Select the disabled state element
:checked Select the selected one Input elements (radio buttons or check boxes)
:default Select the default element
:valid, invalid Select valid or invalid input elements based on input validation
: in-range, out-of-range Select elements within or outside the specified range
:repuired, optional Select input elements based on whether the required attribute is allowed or not
Dynamic Pseudo-class selector :
:link selects the link element
:visited selects the element that the user can access
:hover selects the element on which the mouse is hovering
:ative The event triggered when the mouse clicks
:focus The element currently receiving focus
Other pseudo-class selectors:
:not(
:lang(
:target url fragment The element pointed to by the identifier
:emptySelect the element whose content is empty
:selection The mouse cursor selects the element content
That’s it for the selectors of CSS3, more exciting Please pay attention to other related articles on php Chinese website!
Related reading:
What new background attributes are there in CSS3
How to use CSS3 Media Inquiries
How to make a flexible box in css3
The above is the detailed content of Several commonly used selectors in CSS3. For more information, please follow other related articles on the PHP Chinese website!

One cool thing about CSS custom properties is that they can be a part of a value. Let's say you're using multiple backgrounds to pull off a design. Each

Promises are one of the most celebrated features introduced to JavaScript. Having a native asynchronous artifact baked right into the language has opened up a

I got this question the other day. My first thought is: weird question! Specificity is about selectors, and at-rules are not selectors, so... irrelevant?

Yes, you can, and it doesn't really matter in what order. A CSS preprocessor is not required. It works in regular CSS.

You should for sure be setting far-out cache headers on your assets like CSS and JavaScript (and images and fonts and whatever else). That tells the browser

Many developers write about how to maintain a CSS codebase, yet not a lot of them write about how they measure the quality of that codebase. Sure, we have

Have you ever had a form that needed to accept a short, arbitrary bit of text? Like a name or whatever. That's exactly what is for. There are lots of

I'm so excited to be heading to Zürich, Switzerland for Front Conference (Love that name and URL!). I've never been to Switzerland before, so I'm excited


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft