|
Helping ordinary people create extraordinary websites! |
Use Cascading Style Sheets SelectorsBy Nicholas Chase2004-06-18
The basic page and the universal selector Note: This article shows the use of CSS selectors in browsers such as Microsoft Internet Explorer 6.0 and Netscape 7, but basic selectors are available as far back as Netscape Navigator 4.x and Internet Explorer 4.x. A basic understanding of Cascading Style Sheets is helpful. The basic page and the universal selector To demonstrate the use of different CSS selectors, I use in this article the results of a dog show. I've specifically constructed the page to provide the different examples needed, but otherwise it's a perfectly normal page, as shown in Figure 1 and Listing 1. Figure 1. The basic page
Listing 1. The basic page <html> To start with, create the style element into which the various CSS rules will be placed. The simplest possible style sheet is one that applies a particular rule to all content within the page. Creating such a rule involves creating a style element and a rule using the universal selector, * (See Listing 2): Listing 2. The universal selector <html> While this selector doesn't work in Netscape 4.x browsers, in other cases it applies the style to all appropriate content. The example in Listing 2 applies a font change, as shown in Figure 2. (Some style properties, of course, don't make sense for certain elements. You wouldn't set a font change on a graphic, for example.) Figure 2. The universal selector applies a style to all appropriate content.
Tutorial Pages: » The basic page and the universal selector » Type selectors » Class selectors » ID selectors » Family relationships: descendants, children, and siblings » Pseudo-classes and pseudo-elements » Summary First published by IBM developerWorks |
|