Skip to the content ForoHackers
Log inJoin

CSS: start here

CSS
#3427 · · Quote · 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

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply