liveBook · Manning

CSS

As explained in Web Design Playground

A style sheet language used to describe the presentation of structured documents written in markup languages such as HTML.

HTML gives a web page its structure; CSS gives it its appearance. Think of HTML as a house’s frame and CSS as its paint and finishing touches. CSS stands for Cascading Style Sheets. A style tells the browser how to display something, while a style sheet collects those instructions for a page. section 1.4 section 1.23

A CSS style rule has three small pieces:

  • A selector chooses what to style, such as every h1 heading. section 1.17
  • A declaration pairs a property with a value. In font-size: 36px;, font-size is the property and 36px is the value. section 1.17
  • Braces surround the declarations. A rule can hold more than one. section 7.4

Give every main heading the same size

h1 { font-size: 36px; } The browser applies this rule to every h1 heading on the page. Change 36px once, and all those headings change together. section 1.19

You can put styles directly on an HTML tag, collect rules inside a <style> element in the page’s <head>, or keep them in a separate .css file linked from the page. CSS can change text, backgrounds, spacing, and layout. When rules overlap, inheritance, the cascade, and specificity help determine which styles appear. section 7.12 section 19.22

Your turn

Try writing a rule for h2 that sets font-size to 30px. Add two second-level headings and see whether one rule changes both. section 1.19

How Web Design Playground covers it

How deep it goes
Works through selectors, declarations, and rule syntax, then introduces overlapping rules through inheritance, the cascade, and specificity.
Examples
Uses an h1 font-size rule, an h2 practice prompt, and CSS for landing-page elements.
What it assumes
Introduces HTML tags and CSS properties as basic building blocks rather than assuming prior knowledge of either.
What you can do after
Build it from scratch: write rules that style multiple elements and revise their appearance by changing one declaration.
How it connects
Connects HTML elements and style sheets to selectors, inheritance, the cascade, and specificity.

Also explained in

Compare how 13 books explain CSS →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.