Primary and secondary sequence of CSS stacked styles

Source: Internet
Author: User
Tags tag name

When multiple style sheets are used, the style sheet needs to compete for control of a specific selector. In these cases, there will always be rules for style sheets to gain control. The following features determine the result of a different style sheet.
As previously mentioned, both web page makers and readers have the ability to specify style sheets. When the rules of the two conflict, the rules of the web page maker will prevail over other rules with the same weight of the reader. The style sheets of web page makers and readers go beyond the built-in style sheets of browsers.
Web page makers should be careful when using it! Impant Ant rules, because they will surpass any of the user's! Impant Ant rules. For example, a user may require a large font or a specified color due to the visual relationship, and such a user may declare a definite style rule! Important, because these styles are extremely important for users to read webpages. Any! Impant Ant rules go beyond general rules. Therefore, it is recommended that web page makers use general rules to ensure that users with special style requirements can read the web page.
Selection rule: computing features
Based on their feature levels, a style sheet can also go beyond the conflicting style sheet. A high-characteristic style always prevails over a style with a low feature. This is just a statistical game that calculates the specified number of selector.
Counts the number of ID attributes in the selector.
Count the number of CLASS attributes in the selector.
The HTML tag name format in the statistics selector.
Finally, write three numbers in the correct order. Do not add spaces or commas to get a three-digit number. (Note: You need to convert the number into a larger number ending with three digits .) The final number list corresponding to the selector can easily determine that a higher number is superior to a lower number. The following is a list of feature-specific delimiters:
# Id1 {xxx}/* a = 1 B = 0 c = 0 --> Feature = 100 */
Ul li. red {xxx}/* a = 0 B = 1 c = 3 --> Feature = 013 */
LI. red {xxx}/* a = 0 B = 1 c = 1 --> Feature = 011 */
LI {xxx}/* a = 0 B = 0 c = 1 --> Feature = 001 */
Order of features
For ease of use, when the two rules have the same weight, take the latter one.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.