Introduction to CSS

CSS describes how HTML elements should be displayed — their color, size, spacing, and position on the page.

Linking a stylesheet

The most common way to use CSS is a separate .css file, linked from the HTML document's <head>:

</> index.html
<head>
  <link rel="stylesheet" href="style.css">
</head>

Basic rule syntax

A CSS rule has three parts: a selector (what to style), a property (what aspect to change), and a value (what to change it to). Try changing the color or size below:

Try it yourself
Result

Every declaration ends with a semicolon, and the whole set of declarations is wrapped in curly braces.

Note: CSS can also be written inline on a single element using the style attribute, but a separate stylesheet keeps styling organized and reusable across many pages.