Primary and secondary order of CSS cascading styles

Source: Internet
Author: User
Tags tag name
Css

When more than one style sheet is used, the stylesheet needs to scramble for control over a particular selector. In these cases, there is always the rule of the style sheet to gain control over. The following attributes will determine the results of the opposite style sheet.

As mentioned before, Web page makers and readers have the ability to specify style sheets. When the rules of the two collide, the Web page maker's rules override those of the reader's other same weights. Web page makers and readers have style sheets that go beyond the browser's built-in style sheet.

Web page makers should be careful to use! Important rules, because they will go beyond the user any! Important rules. For example, a user may require a large font or a specified color due to a visual relationship, and such a user would have the possibility to declare a defined style rule for! Important, because these styles are extremely important for users to read Web pages. Any of that! Important rules go beyond general rules, so it is recommended that web makers use general rules to ensure that users with special styles need to be able to read Web pages.

Selector rules: Calculating attributes

Based on their attribute levels, style sheets can also transcend style sheets that conflict with them, and a style with a higher feature always overrides a lower-feature style. This is just a statistical game that calculates the specified number of selectors.

    1. Number of ID attributes in the statistics selector.
    2. The number of CLASS attributes in the statistics selector.
    3. The HTML tag name format in the statistics selector.

Finally, write three numbers in the correct order, without spaces or commas, and get a three-digit number. (Note that you need to convert the number to a larger number that ends with three digits.) The final list of numbers corresponding to the selector can easily determine that a higher numeric attribute overrides a lower number. The following is a list of the selectors sorted by attribute:

#id1         {XXX}/* a=1 b=0 c=0--> feature = */ul UL li.red {XXX}/* a=0 b=1 c=3 attribute =--> 013       {XXX}/* */li.red 0 b=1 c=1--> characteristics = 011 */li           {XXX}/* a=0 b=0 c=1--> feature = 001 *

Order of attributes

For ease of use, when two rules have the same weight, take the one behind.



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.