• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Cascading Style Sheets > Style Syntax

Style Syntax

The syntax of a style — its “rule,” as you may have gleaned from our previous examples — is very straightforward.

The Basics

A style rule is made up of at least two basic parts: a selector , which is the name of the HTML or XHTML markup element (tag name) that the style rule affects, followed by a curly brace ({} )-enclosed, semicolon-separated list of one or more styleproperty:value pairs:

selector {property1:value1; property2:value1 value2 value3; ...}

For instance, we might define the color property for the contents of all the level-1 header elements of our document to be the value green:

h1 {color: green}

In this example, h1 is the selector, which is also the name of the level-1 header element, color is the style property, and green is the value. Neat and clean.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint