Defining the Rules


Style sheet rules are made up of selectors (the HTML tags that receive the style) and declarations (the style sheet properties and their values). In the following example, the selector is the body tag and the declaration is made up of the style property (background) and its value (black). This example sets the background color for the entire document to black.

body {background:black}


You can see that, in a style sheet, the HTML tag is not surrounded by brackets as it would be in the HTML document, and the declaration is surrounded by curly braces. Declarations can contain more than one property. The following example also sets the text color for this page to white. Notice that the two properties are separated by a semicolon.

body {background:black; color:white}


You can format this style rule in a number of ways to make it easier to read. For example, the following rule produces exactly the same results as the preceding style:

body {background:black;        color:white}


So does this:

body {        background:black;        color:white        }


If you want to apply the same rules to several HTML tags, you could group those rules together, as in the following example:

body, td, h1 {                background:black;                color:white                }




Sams Teach Yourself HTML in 10 Minutes
Sams Teach Yourself HTML in 10 Minutes (4th Edition)
ISBN: 067232878X
EAN: 2147483647
Year: 2004
Pages: 151
Authors: Deidre Hayes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net