Skip to the content ForoHackers
Log inJoin

CSS: start here

CSS
#921 · Ophuscado · · Report

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

  1. Style a plain HTML document using only element and class selectors, and inspect the cascade in developer tools.
  2. Draw the box model of five elements and predict their sizes before measuring.
  3. Build the same layout with flexbox and then with grid.
  4. Make a page work from a narrow phone to a wide monitor with no horizontal scroll.
  5. Add a dark theme and a print stylesheet using custom properties and media queries.

Related tags

#frontend #web-standards #accessibility #interface-design

Log in or join to reply.