CSS Syntax & Layout

Types of Selectors

Defining CSS Styles

Basic Syntax

selector {property: value;}

Multiple Properties

All specified properties will apply itself to the specified selector.

selector {property: value; property: value; property: value;}

Grouping

All specified properties will apply itself to each of the specified selector

selector, selector, selector {property: value; property: value; property: value;}

Example 1

It is important to keep in mind that the country was large and sparsely settled, that communication was primitive, and that the central government did not influence the lives of most people to any great degree. Many persons, including some who had been in the forefront of the struggle for independence, believed that a centralized republican system would not work in a country so largeand with so many varied interests as the United States. Patrick Henry considered the Constitution "horribly frightful." It "squints toward monarchy," he added. That Congress could pass all laws "necessary and proper" to carry out the functions assigned it and legislate for the "general welfare" of the country seemed alarmingly all-inclusive. The first sentence of the Constitution, beginning "We the people of the United States" rather than "We the states," convinced many that the document represented centralization run wild. Another old revolutionary who expressed doubts was Samuel Admas, who remarked: "As I enter the Building I stumble at the Threshold."

Example 2

The Box Model

Whitespace
Margin
Border
Padding
Content