All selectors and css properties. Types of CSS selectors


Selector determines which element to apply a particular CSS rule to.

Basic selectors

Element Selectors This basic selector selects the element to which the rule will be applied.
Syntax:element
Example: the input selector will select all elements used to create interactive controls in web forms. "> ... Selectors by Class This basic selector selects elements based on the value of their class attribute.
Syntax: .class name
Example: the .index selector will select all elements with the appropriate class (which was defined in the attribute class = "index" or similar). ID Selectors This basic selector selects elements based on the value of their id attribute. Remember that the identifier must be unique, that is, it must be used for only one element in the HTML document.
Syntax:#IDName
Example: the #toc selector will select the element with the id toc (which was defined in the id = "toc" or similar attribute). Universal Selector This basic selector selects all items. It also exists in local and global namespaces.
Syntax:* ns | * * | *
Example: selector * will select all elements. Attribute Selectors This basic selector selects elements based on one of their attributes and / or its value.
Syntax:
Example: the selector will select all elements with the autoplay attribute (regardless of its value).

Combinators

The + combinator matches an element that is immediately after the specified element if they have a common parent.
Syntax: A + B
Example: the ul + li selector will select any element that is immediately after the element