Chapter 2. Using CSS Rules

In this lesson, you will learn the syntax and rules of the Cascading Style Sheet (CSS) language. You will learn the components of CSS rules, including selectors, declarations, properties, and values. You will learn how to style a series of simple HTML elements. You will also learn how to use shorthand properties.

Setting Up the HTML Code

The HTML code for this lesson will be comprised of three elements—<h1>, <h2>, and <p>, as shown in Listing 2.1.

Example 2.1. HTML Code Containing the Markup for Lesson 2

<h1>
    Level 1 heading
</h1>
<h2>
    Level 2 heading
</h2>
<p>
    Lorem ipsum dolor sit amet, consectetuer...
</p>

Creating a Rule Set

A rule, or rule set, is a statement that tells browsers how to render particular elements on an ...

Get Sams Teach Yourself CSS in 10 Minutes 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.