Css selector priority, css Selector
<Html>
<Head>
<Title> cascade feature </title>
<Style type = "text/css">
P {color: green}
. Red {color: red ;}
. Purple {color: purple ;}
# Line3 {color: blue ;}
</Style>
</Head>
<Body>
<P> This is the first line of text </p>
<P class = "red"> This is the second line of text </p>
<P id = "line3" class = "red"> This is the third line of text </p>
<P style = "color: orange;" id = "line3"> This is the fourth line of text. </p>
<P class = "purple red"> This is the fifth line of text </p>
</Body>
<Html>
Category Selection has a higher priority than the tag Selector
The ID selector is higher than the category selector.
The intra-row style has a higher priority than the category selector.
The preceding style has a higher priority than the latter
What is the priority of the CSS selector?
In this Code, the p tag first uses the. red style, and the second is the style defined by the p tag.
That is to say, if the style in the p label is the same as that in. red, the. red style will be used first. If the style of the p label is not in. red, the style is valid for the p label. That is, css inheritance, such as rewriting and writing code:
<Style type = "text/css">
. Red {font-size: 14px; color: red ;}
P {color: blue; font-size: 24px; text-decoration: underline}/* underline the p tag to see the effect */
</Style>
What is the priority of the CSS selector?
In this Code, the p tag first uses the. red style, and the second is the style defined by the p tag.
That is to say, if the style in the p label is the same as that in. red, the. red style will be used first. If the style of the p label is not in. red, the style is valid for the p label. That is, css inheritance, such as rewriting and writing code:
<Style type = "text/css">
. Red {font-size: 14px; color: red ;}
P {color: blue; font-size: 24px; text-decoration: underline}/* underline the p tag to see the effect */
</Style>