Style sheets priority order

前端 未结 3 934
南旧
南旧 2020-12-10 00:57

If I have the following style sheets:

user important declarations
user normal declarations
author normal declarations
user agent declarations
author importan         


        
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 01:22

    Below content is taken from here.

    Style property can appear in any number of style sheets, and several times inside a single style sheet. Therefore, order of applying the rules is very important. This is called the "cascade" order. According to CSS2 spec, the cascade order is (from low to high):

    1. Browser declarations
    2. User normal declarations
    3. Author normal declarations
    4. Author important declarations
    5. User important declarations

    a) The browser declarations are least important;
    b) User overrides the author only if the declaration was marked as important.
    c) Declarations with the same order will be sorted by specificity and then the order they are specified.
    d) The HTML visual attributes are translated to matching CSS declarations.
    e) They are treated as author rules with low priority.

提交回复
热议问题