JavaScript EditorBest javascript editor debugger     Ajax website 



Main Page

Previous Page
Next Page

9. Defining Selectors

As you saw in Constructing a Style Rule on page 120, there are two principal parts of a CSS style rule. The selector determines which elements the formatting will be applied to and the declarations define just what formatting will be applied. In this chapter, you'll learn how to define CSS selectors.

While the simplest selectors let you format all the elements of a given typesay, all the h1 headersmore complex selectors let you apply formatting rules to elements based on their class or id, context, state and more.

Once you've defined the selectors, you can go on to create the declarations (with actual properties and values) in Chapters 1014. Some more specialized style properties are discussed throughout the rest of this book. Until then, we'll use the very simple and relatively obvious {color:red;} in our examples.


Previous Page
Next Page


      Constructing Selectors
      Selecting Elements by Name
      Selecting Elements by ID or Class
      Selecting Elements by Context
      Selecting Part of an Element
      Selecting Link Elements Based on Their State
      Selecting Elements Based on Attributes
      Specifying Groups of Elements
      Combining Selectors


JavaScript EditorBest javascript editor debugger     Ajax website