Home >Web Front-end >CSS Tutorial >What are the syntaxes for selectors in CSS3
Today I will introduce to you the commonly used selector syntax in CSS3. The syntax is generally divided into three types, basic selector syntax, hierarchical selector syntax and dynamic pseudo-class selectorgrammar. Let me give you a detailed explanation below.
1. Basic selector syntax
(1)* Wildcard selector Selects all HTML elements in the document
(2)E Element selector Select the HTML element of the specified type
#id ID selector Select any type of element with the specified ID attribute value as "id"
.class Class selector Select the specified class attribute value as "class "Any multiple elements of any type
selector1,selectorN Group selector Merge the set of elements matched by each selector
2, Hierarchical selector syntax
(1)E F Descendant selector (including selector) Selects the matching F element, and the matching F element is included in the matching E element
(2)E>F Child The selector selects the matching F element, and the child element of the E element matched by the matching F element
(3)E+F Adjacent sibling selector Selects the matching F element, And the matching F element is located immediately after the matching E element
(4)E~FUniversal selectorSelects the matching F element, and is located after the matching E element all matches F element
3, dynamic pseudo-class selector syntax
(1)E:link Link pseudo-class selector selects the matching E element, and the matching element is defined and the hyperlink is not been visited. Commonly used on link description points
(2)E:visited Link pseudo-class selector selects matching E elements, and the matching elements are defined with hyperlinks and have been visited. Commonly used on link drawing points
(3)E:active User behavior selector selects the matching E element, and the matching element is activated. Commonly used on link drawing points and buttons
(4)E:hover User behavior selector Selects the matching E element, and the user's mouse stays on the element E. IE6 and below browsers only support a:hover
(5)E:focus The user behavior selector selects the matching E element, and the matching element gets focus
I believe you have mastered the method after reading the above introduction. For more exciting information, please pay attention to other related articles on the php Chinese website!
Related reading:
How to use H5 to create fireworks particle effects
Tutorial on making div width adaptive
Development experience using h tags in web pages
The above is the detailed content of What are the syntaxes for selectors in CSS3. For more information, please follow other related articles on the PHP Chinese website!