×
Course: CSS Basics

CSS Rules [2/15]

CSS code consists of repetitive blocks having the following format:

selector {
  property1: value;
  property2: value;
}

Such a block is referred to as a "CSS rule". Each CSS rule contains at least one selector and one property.

The simplest selectors are tag name selectors. With them you can set common styling for all paragraphs in your page, for all its links, first-level headings, etc. Such selectors contain the tag name stripped of < and >. For example:

p {
  /* styles for paragraphs */
}

h1 {
  /* styles for headers */
}

Do it
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS Rules</title> </head> <body> <h1>1. Headings</h1> <p>Headings are core to text structuring.</p> <h2>1.1 Using Headings and Subheadings</h2> <p>Here are some guidelines on using headings in an HTML page.</p> <h3>1.1.1 Using h1</h3> <p>If you are not using the &lt;section&gt; or &lt;article&gt; tags, we would not recommend you to have several top-level headings on a same page. However every &lt;section&gt; and &lt;article&gt; tag can have its own hierarchy of headings.</p> <h3>1.1.2 Use of Sub-Headings (h2-h6)</h3> <p>Try to avoid skipping heading levels; so, h1 should be followed by h2 and then by h3.</p> </body> </html>
CSS
HTML Academy
  1. Create a CSS rule for paragraphs with color: #999999;
  2. Create a CSS rule for level-1 headings with font-family: Tahoma;
  3. Create a CSS rule for level-2 headings with color: #0088cc;.
Theory Check Next