Chapter 2. How CSS Works

You saw in Chapter 1 how the structure of a document is created with HTML. In this chapter, I will show you how CSS rules are used to style HTML, and explain the workings of the Cascade, which is how CSS resolves which style is applied when more than one style affects an element property.

Each HTML element has style properties that can be set with CSS. These properties relate to the different visual aspects of the element, such as its position onscreen, the width of its border, the size, color, and fonts of its text, and so on. CSS is a mechanism for selecting HTML elements and then setting the selected elements’ CSS properties. Each CSS selection and the associated styles that are applied is called a CSS rule.

This ...

Get Stylin’ with CSS: A Designer’s Guide, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.