8. CSS selector
8.1. Tag selector
Function: Set the style for a certain tag specified on the page.
Code:
Disadvantage: Only a certain type of label can be styled.
8.2, class (class) selector strong>
Function: Set the style for a certain label of the specified class name. Each label can be set with a class attribute. The attribute value following the class is called the class name.
Code:
8.3. id selector
Function: Set the style for the tag with the specified id name. Each tag can be set with an id attribute, and the attribute value after id is the id name.
Code:
**8.4. Points to note about class name and id name***
class name: equivalent to a small name of the label (can be repeated);
id name: equivalent to the certificate number of the label (not allowed to be repeated);
? One class name can be used for multiple tags, and one id name can only be used for one tag.
? The specification of class name and id name: it can only be composed of English letters, numbers, underscores and hyphens (-), and numbers cannot start, and underscores and hyphens cannot start either (can be used, but not Suggest).
8.5. Wildcard selector
Function: Used to set styles for all tags on the page, often used for page style initialization operations.
Code:
Note: When the wildcard selector is set, it will traverse all the tags on the page and set the styles for these tags.
Disadvantages: performance is too low, mainly used for initializing styles.
Comprehensive exercise: Baidu homepage