Одакле потичу стилови: три порекла
CSS isn't your stylesheet alone
Every element on a page has a "computed style" — the final answer the browser uses to paint it. That answer is the result of merging styles from THREE origins. For normal (non-!important) declarations the priority is, lowest to highest:
- User-agent (browser defaults) —
<h1>is bold and 32px because Chrome says so.<a>is blue and underlined. Lists have bullets. Margins exist between paragraphs. - User styles — custom CSS the user applies in browser settings (rare; mostly accessibility). You can ignore this origin for now.
- Author styles — your CSS files +
<style>blocks + inlinestyle=""attributes. Inline styles are still the author origin, but the cascade has a dedicated step for them: an element-attached declaration beats any normal selector.
`!important` REVERSES the origin order. Important declarations are sorted in their own, upside-down band: important user-agent > important user > important author > normal author > normal user > normal user-agent. So an author's !important beats the author's normal rules, but a user's !important accessibility rule beats the author's !important.
Inside one origin the tie-breakers are, in order: inline style, @layer order, specificity, then source order (last wins). A small specificity note: :is() takes the specificity of its most specific argument, while :where() always contributes zero — handy for low-specificity base styles.
The "starts working from nothing" mistake
Junior devs often look at a default <h1> and wonder "why is this so big?" — they don't realize the browser already gave it 32px and margin. Modern projects ship a reset or normalize stylesheet first:
/* Modern minimal reset */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; }Two lines that solve 80% of "why does my hero have a tiny gap at the top?"
What this module is about
- Lesson 2: how the browser PICKS which selector wins (specificity).
- Lesson 3: which properties cascade from parent → child (inheritance).
- Lessons 5-7: the box model — content, padding, border, margin.
- Lessons 8-9:
box-sizing: border-boxand why it's a default. - Lesson 10: capstone combining all the above.