CodeBlanks Logo Icon CodeBlanks

What is CSS?

CSS course · Beginner · Lesson 1/82

Learn what CSS is, how it differs from HTML, and how it styles a page.

What is CSS?

CSS stands for Cascading Style Sheets. It is not a programming language, it is a styling language. Its job is to describe how an HTML page should look: colors, fonts, spacing, layout.

The browser reads the HTML, applies the CSS declarations it finds, and draws the result on screen. The same HTML document can look completely different with different CSS.

HTML structure, CSS style

HTML builds the structure of the page: headings, paragraphs, links, images. CSS decides the style of that same page: color, size, alignment, spacing.

For example, the body tag wraps the whole page. With CSS you give the body selector a color, and the whole page picks it up. This split lets you keep two files: HTML for content, CSS for appearance.

The stylesheet

CSS declarations together form a stylesheet. It is a plain text file ending in .css; it holds rows of selectors and declarations.

A single stylesheet can style hundreds of pages. Change the file once, and every page on the site updates at the same time. This makes it easy to keep a site consistent.

Exercise Set a color for body

Write a body selector and add a color: #333 declaration inside. This makes all text on the page dark gray.

Show example solution
/* add the body style */
body {
  color: #333;
}

Test yourself

  1. What does CSS determine?

    body {
      color: navy;
      font-family: sans-serif;
    }
    • The structure and content of the page
    • Data exchange with the server
    • The appearance and styling of the page
    • Database queries
    Show answer

    The appearance and styling of the page — Correct. CSS determines style properties like color, font and spacing.

  2. Match each term to its meaning

    CSS
    Styling language
    HTML
    Markup language
    Stylesheet
    .css file
    Browser
    Draws code on screen
  3. Select the page body

    ____ {
      color: #333;
      line-height: 1.5;
    }
    Show answer
    body {
      color: #333;
      line-height: 1.5;
    }

All lessons in Beginner