CSS introductory notes 2: four basic selectors

1. Tag selector: use the tag name as the name of the selector

Function: You can quickly select the same type of labels

Advantages: can quickly set a uniform style for the same type of label in the page

Disadvantages: Cannot set the label content style differentially

2. Class selector (most commonly used in development)

Advantages: differentiate the style of the label content.
Syntax:

.类名 {
    
    
     属性1: 属性值;
     ...+
     }

use

<标签 class="类名1 类名2 ...">

Note: Multi-class names actually achieve commonality extraction , that is, group the same attributes into one class

3.id selector
Syntax:

     #类名{
    
    
     属性1: 属性值;
     .....
     }

use:

<标签名 id="id选择器名">

Note: The id selector can only be called once, when the id selector is called once by a label, it cannot be used anymore

4. Wildcard selector
Syntax:

          * {
    
    
				属性1: 属性值;
				.....
				}

Role: Change all labels to a uniform style

Summary of selectors:
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_52021758/article/details/113008349