Grammar
<style type="text/css>
</style>
Tag Selector
li {
color: red;
}
ID Selector
#li{
color: yellow;
}
Unique, the same page can only have one
Higher precedence than Class selector
class Selector
.li{
color: blue;
}
Higher precedence than the tag Selector Universal Selector Lowest priority level
*{
}
Descendant Selector
div li{
color:red;
}
> Descendant Selector, you can only select the next level of class or tag, not leapfrog
div>ul>li{
color:red;
}
Intersection Selector
.li#li{
/*
元素必须同时满足.li和#li才能使用
*/
}
and set Selector
.li,#li,div{
/*
元素只要具备一个条件即可生效
*/
}
CSS3 New SelectorSelector Priority 1. First principle: Near-priority, the most inner selector is always preferable to the outer layer
Example: Div ul li >div #ul, Li in the UL inner layer, so the Li tag Selector can overwrite the outer ID selector
2. When acting on the same layer, the ID selector >class Selector > tag Selector
Example: Div #li >div. Li>div Li
3. As used for the same layer, and the last layer selector does not have a precedence relationship (both class or ID)
Example: Div ul Li >div Li, the scope of the selection of more accurate, then higher priority
4. When the precedence is identical, the following selectors overwrite the previous selector in the Order of code execution
Null
CSS (selector)