CSS

CSS stands for Cascading Style Sheets. It is the language we use to style an HTML document. At a high level, HTML is intended to provide the structure of a document, through tags, while CSS can be seen as the presentation layer of that structure: color, spacing, layout, and much more. CSS also enables the user to specify how the content should be presented across different types of media and different sized screens.

CSS is a rule-based language, which allows us to concisely specify how we want different parts of our HTML pages to look like. It allows us to declare things like I want all paragraphs on my HTML page to be red over a blue background, with a 16pt font size, in a machine-readable language. Writing this verbal rule in CSS looks like this:

p {
    color: red;
    background-color: blue;
		font-size: 16pt;
}

What you see above is a rule. A stylesheet (CSS file) consists of multiple rules like this one, which get applied to various parts of our HTML page.

The syntax of an individual rule consists of:

Using CSS on a webpage

There are three main ways of styling an HTML page. They all use the same CSS language and syntax, but are different in where the CSS code lives. We’ll mostly use the third option, but it’s important to be aware of all three.

CSS properties