Hi, I'm Nicholas Johnson!

software engineer / trainer / AI enthusiast


HTML is a tree. We nest elements inside and underneath each other.

We can pull off parts of this tree for styling using CSS selectors.

Style tags

We can put CSS onto our page using a style tag. Later we’ll see how we can extract our styles into a separate document.

  /* Styles go here */

We then write selectors to trim parts of the tree, and add rules, like this:

  h1 {
    color: red;
    font-size: 30px;
  p {
    color: blue;

We can put the style tag in the head of our page like so:

<!DOCTYPE html>
      /* Styles go here */
    <h1>CSS Selectors are better</h1>
      Because they apply
      <strong> to the whole page! </strong>

Exercise - Style the page

Use a style tag and selectors to solve the following:

  1. Make the h1 font-weight: normal
  2. Style the body using a sans-serif font.
  3. Add a couple of dozen lines of text to the paragraph. Now set line-height:2em for double spacing.
  4. Add a couple ore paragraphs. Set top and bottom margins to add spacing between the paragraphs.
  5. Use letter-spacing:0.1em on the paragraphs to open the text out a little.