CSS Syntax
-
The basic syntax of a style in CSS is made up of 3 sections:

- The selector is where you put the HTML element name (or ID or class) you want to define rules for. For example the header h1.
- The property is the property you want to change for that particular selector. For example let’s change the color of our h1.
- The value is the value for the property you want to change. For example let’s set all h1’s color to be red.
- For each selector you can have multiple property, value combinations.
- The rule or whole CSS syntax would look like this if we wanted all h1’s
on the site to be red.
- h1 {color: red;}
Including CSS
There are several ways to include CSS:
- You can call CSS from an external file in two ways:
-
Using a
linkelement:
<link rel="stylesheet" href="/css/master.css" type="text/css" media="screen" title="no title" charset="utf-8" /> -
Importing it from within the style declaration:
@import url('/css/master.css');
-
Using a
-
You can write it into the style declaration:
<style type="text/css">
body {padding: 25px;}
[...]
</style> -
You can use an inline style attribute:
<h1 style="color: red;">Headline</h1>