Basic CSS Structure & Syntax

CSS Declarations: Anatomy

It's not enough to simply select an HTML element in a CSS file. To actually style the element, you need to specify two things inside the body of the selector:

  1. Property - the property you'd like to style of that element (i.e., size, color, etc.).
  2. Value - the value of the property (i.e., 18px for size, Blue for color, etc.).
h1 { color: Blue; }

In the example above, the <h1> element has been selected. Inside of the selector's body, the heading's color property is set to a value of Blue. The heading will now appear the color blue in the browser.

The line color: Blue; is referred to CSS declaration. A CSS declaration consists of a property and a value. Note that a semicolon (;) ends all declarations.

Finally, the entire snippet of code in the example above is known as a CSS rule. A CSS rule consists of the selector and all declarations inside of the selector.

Report a Bug
If you see a bug or any other issue with this page, please report it here.