News & UpdatesProgrammingWeb programming Store My Projects
Links
Affiliates

CSS Tutorial – 02 – Rule Structure

Every style sheet is made up of a list of rules. For example, a rule to color all paragraph elements red looks like this:

p { color: red; }

This rule has two parts: a selector (p) and a declaration block, consisting of one or more declarations enclosed in curly braces. The selector declares which elements the style will be applied to. In this case to all paragraph elements. Following the selector comes the declarations, each of which is made up of a style property followed by a colon and a valid value for that property. Each declaration is terminated with a semicolon, although this is optional for the last one.

p { color: red; background: black }

Sections