Selectors, Properties, and Values: Basic CSS Concepts
Last edited by admin Wed, 10/03/2012 - 20:14


The basic structure of an CSS declaration

Every CSS document is composed of many CSS declaration that follow the same syntax. It is of the form:

Selector {property: value}


Selectors can be page elements, div elements, or class elements. Page elements can be recognized by the absence of any symbol before the element's name. Divs are written as #div_name, and classes as .class_name.

backround-color: red;

font-color: green;

line-height: 12px;


In the above example, backround-color, font-color and line-height are examples of properties that define the selectors.
For a full list of properties, see the CSS cheetsheat.


The values for the properties from the example are obviously red, green, and 12px. Values for CSS properties can be hexadecimal notation for colors or the names of the colors, zero, or positive and negative integers for pixel and em values.