Reputation: 125
I've got a question about CSS files and it's order of applying in browser. We have:
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?
Upvotes: 1
Views: 3436
Reputation: 201548
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) !important
declarations trump everything but user !important
declarations. 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.
Upvotes: 2
Reputation: 37537
No. User CSS files will be parsed after a site CSS files (otherwise it wouldn't make any sense to have a user CSS file). That doesn't mean it will automatically override everything in a website's css file however, normal CSS specificity rules still apply.
Let's make all paragraphs red for an example my website has the rule:
website.css: p { color: red; }
But if I implement a user style sheet (like userContent.css in FireFox) and say:
FireFox userContent.css: p { color: blue; }
The text color would be blue.
If I then mark the website's rule important:
website.css: p { color: red; !important }
The color would be red again.
Upvotes: 0