The effect of CSS location
Finally, it is also useful to note that the importance of a CSS declaration depends on what stylesheet it is specified in — it is possible for users to set custom stylesheets to override the developer’s styles. For example, the user might be visually impaired, and want to set the font size on all web pages they visit to be double the normal size to allow for easier reading.
I didn’t quite get what “CSS Location” means. The user will not be able to overwrite some CSS rules by simply adding another <link>
in the HTML document.
The browser will parse trough both CSS files and pick the rules based on specificity, right??
Also, what do you mean by user setting custom style sheets anyway? I can’t load another CSS file one someone else’s web page. Do you mean the user can manually edit the properties using the dev tools?
To summarize
Conflicting declarations will be applied in the following order, with later ones overriding earlier ones:
- Declarations in user agent style sheets (e.g. the browser’s default styles, used when no other styling is set).
- Normal declarations in user style sheets (custom styles set by a user).
- Normal declarations in author style sheets (these are the styles set by us, the web developers).
- Important declarations in author style sheets
- Important declarations in user style sheets
I’m struggling to understand this part as well.
-
Clearly these are the default browser styles. I understand this
-
and 3. I don’t understand the order here. What are these user declarations? Where are they coming from? I understand that normal developer declarations will overwrite default browser styles, that’s what CSS is for. But how can a user implement his styles so that they loose in cascade battle (Again does this have to do with dev tools? But you said above that user can use their styles and overwrite developer’s styles.)
4 and 5. Again, I don’t understand the concept of user styles, but why is the order here reversed compared to bullet points 2 and 3 ? Here, the user !important rules have the advantage over developer’s !important rules. (This kinda makes sense since it will be later in the cascade)
Sorry for the longer post, but I’m missing something and I went through the whole lesson a couple of times. Everything is 100% clear except this last part.
Also, thank you for this amazing content and course. The world would be better place if more people were like you!!