I’ve got a question about CSS files and it’s order of applying in browser.
We have:
- browser (system) CSS file,
- user CSS file,
- user CSS important file,
- site CSS file,
- site CSS important file,
When page is loaded some of CSS code replace other code depending on order or !important word. Is order I listed above correct, so site CSS important file can override all previous styling?
CSS code does not replace other CSS code, and the order of parsing style sheets is not relevant. There is really no order of application, since all applicable style sheets are taken into account. When several style sheets assign a value to a property of an element, then the conflict is resolved according to cascade rules. The order is then:
user agent declarations (browser default style)
user normal declarations
author (page) normal declarations
author (page) important declarations
user important declarations
So author (page)
!importantdeclarations trump everything but user!importantdeclarations. In Css 1, the order was different, but this was changed in CSS 2 and browsers live by the current rules: the user always has the last word, if he wishes to exercise his rights.