CSS Basics · Lesson 1 of 11

Your First Style Rule

CSS is a list of rules. Each rule picks some elements and says how they should look:

h1 {
  color: blue;
}

A rule has three parts:

  • The selector (h1) says which elements the rule is for. Here: every <h1> on the page.
  • The property (color) says what to change. color is the color of the text.
  • The value (blue) says what to change it to.

The property and value sit inside curly braces, with a colon between them and a semicolon at the end. One rule can hold as many of these lines as you like:

p {
  color: gray;
  font-size: 18px;
}

Where the CSS goes

The editor now has two tabs. index.html holds the page, and style.css holds its styles. On a real site the two files are connected by a <link> tag in the page's head. Here that is done for you.

CSS knows about 140 color names, such as red, navy, tomato, gold and teal. You will meet more exact ways to write colors soon.

Your Task

  1. In style.css, make the <h1> text teal.
  2. Add a second rule that makes all <p> text gray and sets its font-size to 18px.
  • The heading text is teal
  • The paragraphs are gray
  • The paragraphs have a font size of 18px