Μετάβαση στο κύριο περιεχόμενο
Το Frontend είναι ένα δωρεάν μπόνους στο CodeMentor AI — το κύριο προϊόν είναι η Python. Εγγραφείτε για να αποθηκεύσετε την πρόοδό σας και να ξεκλειδώσετε όλα τα 299 μαθήματα Frontend + 1,100+ μαθήματα Python.Εγγραφή — δωρεάν
← 🎨 CSS as a design system·Ενότητα B1 · Μάθημα 1
ΕργασίαOverride the default h1 size. Set body margin to 0, and h1 font-size to 48px with color #3B82F6.

Από πού προέρχονται τα στυλ: οι τρεις καταβολές

50 XP6 minFREE
Θεωρία

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:

  1. 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.
  2. User styles — custom CSS the user applies in browser settings (rare; mostly accessibility). You can ignore this origin for now.
  3. Author styles — your CSS files + <style> blocks + inline style="" 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-box and why it's a default.
  • Lesson 10: capstone combining all the above.
2 καρτέλες
Ζωντανή προεπισκόπηση
← Στη διαδρομήΕπόμενο μάθημα →

Μια συμβουλή Python ή web την ημέρα — με email

Σύντομο, γραμμένο στο χέρι, χωρίς spam. Διαγραφή με ένα κλικ.