- Rule = selector { property: value; }.
- Locations: inline (style attribute), embedded (<style> in head), external (.css file via <link>). External is best for reuse.
- .class selects many elements; #id selects one unique element.
🎯 How this can come up · 1 question
Which selector targets the element with id="main"?
Correct: #main.
- Pseudo-classes describe a state (:hover, :visited, :first-child); pseudo-elements a part (::first-line, ::before).
- Contextual: descendant (div p), child (div > p), adjacent sibling (h1 + p), general sibling (h1 ~ p).
🎯 How this can come up · 1 question
"ul > li" selects:
Correct: li elements that are direct children of ul.
- The cascade resolves conflicts by inheritance, specificity, then location (later rules win).
- Specificity: inline style > id > class/attribute/pseudo-class > element. !important overrides.
🎯 How this can come up · 1 question
Which wins: "#title { color: red }" or ".heading { color: blue }" on the same element?
An id beats a class regardless of order.
- Block elements start on a new line and fill the width (div, p, h1). Inline elements flow within text (span, a, img).
- Box model: content → padding → border → margin. With box-sizing: content-box, width excludes padding and border; border-box includes them.
🎯 How this can come up · 1 question
width: 200px; padding: 10px; border: 5px; (content-box). Total rendered width:
200 + 2×10 + 2×5.
- CSS variables: --main-color: #333; use with var(--main-color).
- Flexbox: ONE-dimensional layout (a row or a column). Container: display: flex; justify-content (main axis), align-items (cross axis), flex-wrap, flex-direction.
🎯 How this can come up · 1 question
In a flex row, which property aligns items horizontally along the main axis?
Correct: justify-content.
- Grid: TWO-dimensional layout. grid-template-columns: 1fr 2fr; grid-column / grid-row placement; named areas.
- Responsive design: layouts that adapt to screen size: fluid grids, flexible images, media queries.
- <meta name="viewport" content="width=device-width, initial-scale=1"> stops mobile browsers from zooming out a desktop layout.
- @media (max-width: 600px) { … } applies rules only when the condition is true.
🎯 How this can come up · 1 question
Which applies styles only on screens 600px wide or less?
Correct: @media (max-width: 600px).
No slides match this filter.



































































