Label selector

div {
     color: red;
}
Copy the code
  • Advantages: Can quickly set styles for the same type of tags on the page
  • Disadvantages: can’t differentiate styles, can only select all current tags

Class selectors

.hobby {
    	color: red;
}
Copy the code

Usage scenarios in multi-class name development

  • You can put some tag elements in the same style in a class
  • Each of these tags can call this common class and then call its own unique class
  • Each class name is separated by a space
  • Multi-class name selectors are often used when the layout is complicated

The id selector

The ID selector is defined with “#”

#pink {
	color: pnik;
}
Copy the code
  • The biggest difference between id selectors and class selectors is the number of times they are used
  • Class selectors are most commonly used to modify styles, and ID selectors are typically used on unique elements of a page, often in conjunction with javascript
  • The ID selector can only be called once. Do not use it by others

Wildcard selector

* {properties1: attribute values1;
}
Copy the code
  • The wildcard selector automatically styles all elements without needing to be invoked
  • Only for special circumstances
* {
	margin: 0;
	padding: 0;
}
Copy the code