CSS is the language that describes how a web page looks: colours, type, spacing, and above all layout. It is declarative: you state rules and the browser works out the result for every screen size. It looks easy at first and rewards a real understanding of how its rules combine.
Key concepts
- Selectors and the cascade: many rules can match one element, and origin, specificity and order decide which wins.
- The box model: every element is a box with content, padding, border and margin.
- Layout modes: normal flow, flexbox for one dimension, grid for two, and positioning for exceptions.
- Responsive design: fluid sizes, relative units and media or container queries adapt one page to many screens.
- Custom properties: variables that let a theme change in one place, even at run time.
Vocabulary
- Specificity: a ranking of how precisely a selector targets an element.
- Pseudo-class: a selector for a state, such as hover or focus.
- Viewport: the visible area of the page in the browser.
- Reset: a small stylesheet that evens out the browser defaults.
What to study, in order
- Style a plain HTML document using only element and class selectors, and inspect the cascade in developer tools.
- Draw the box model of five elements and predict their sizes before measuring.
- Build the same layout with flexbox and then with grid.
- Make a page work from a narrow phone to a wide monitor with no horizontal scroll.
- Add a dark theme and a print stylesheet using custom properties and media queries.