Style overlay order in CSS style sheets

Source: Internet
Author: User

Style overlay order in CSS style sheets--Iteye technology website

Focus on the induction:

Find some textbooks (w3schools, etc.), just say that the order of the CSS is "style on the element" > "style element on file header" > "External Style File", but the precedence of multiple same styles in the style file is not explained in detail. After testing and continuing the search, you know that the priority is listed as follows:

Or the following can also be called a number of priority principles (by Liwei 20140803)

1. The more precise the element selector selection of a style sheet, the higher the style precedence :

The ID selector Specifies the style > class selector for the specified style > element type selector for the specified style

So in the example above, #navigator的样式优先级大于. Current_block priority, even if. Current_block is newly added and does not work.

2. For styles specified by the same type selector, the higher the precedence in the style sheet file

Note that this is the higher priority in the style sheet file, rather than the order in which the element class appears. (See the original for a specific example).

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: 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.