1. Three styles of CSS style code insertion:
Priority, remember their priorities:内联式 > 嵌入式 > 外部式
But embedded > external has a premise: the placement of the embedded CSS style must be behind the exterior.
in fact, in conclusion, it is --就近原则(离被设置元素越近优先级别越高) .
2 . Differences between class and ID selectors
The ID selector can only be used once in a document . Unlike class selectors, an ID selector can only be used once, and only once, in an HTML document. The class selector can be used more than once.
A1: What is the main difference between the two?
ID you can only use to define a single element, define two later. There is no problem with the page, but W3 detects that your page does not conform to the standard; class is classes, and the same class can define multiple elements. As far as the page effect is concerned, the visual effects of two items are almost no different.
Why is the a2:id selector less used, and what are its limitations?
Single use of the style with ID, need to program, JS dynamic control style with Id,id in the page can only be used once! Provide a less-used ID because the ID may conflict with a page-embedded program (such as the same name)!
A3: When should I use my id and when do I use class?
A single element, or something that requires a program or JS control, needs to be defined with an ID, a reusable element, a class, and a class definition.
CSS Learning Notes