Fundamentals for CSSs
CSS fundamentals are the selectors, the cascade and the box model. Selectors pick elements, the cascade decides which rule wins using origin, specificity and source order, and the box model describes every element as content, padding, border and margin. Nearly every layout bug traces back to one of these.
Stage: Core CSS · Part of the CSS roadmap · Last reviewed 19 November 2026
What to learn in Fundamentals
- Select elements with type, class, ID, attribute and descendant selectors
- Calculate which of two rules wins using specificity
- Explain how content, padding, border and margin make up an element's box
- Switch to box-sizing: border-box and see how widths change
- Describe how inheritance passes some properties to child elements
Fundamentals interview questions
How does CSS decide which rule wins when two conflict?
The cascade compares importance and origin first, then selector specificity, then source order, where the later rule wins ties. An ID selector beats a class, which beats a type selector. Using !important overrides normal order and should be rare.
What does box-sizing: border-box change?
By default, width applies to the content box, so padding and border add to the total size. With border-box, width includes padding and border, so a 300px element stays 300px wide, which makes layout arithmetic predictable.
Where Fundamentals fits in the CSS roadmap
Fundamentals belongs to the Core CSS stage (beginner level), which takes about 17 hours. Selectors and the box.