Developer Forums | About Us | Site Map
Search  
HOME > TUTORIALS > CLIENT SIDE CODING > CSS TUTORIALS > USE CASCADING STYLE SHEETS SELECTORS


Sponsors





Useful Lists

Web Host
site hosted by netplex

Online Manuals

Use Cascading Style Sheets Selectors
By Nicholas Chase - 2004-01-28 Page:  1 2 3 4 5 6

ID Selectors

Another specialty selector is the ID selector. Like the class, an ID selector is based on the value of an attribute, but in this case, it's the ID attribute. This selector is used to single out a particular element; IDs should be unique within a document. For example the following code in Listing 6 selects the span designated as bestinshow by preceding the name with a pound sign (#) and colors it red, as shown in Figure 5.

Listing 6. Using the ID selector

    
...
   <style type="text/css">
      * { font-family: Verdana }
      td { font-size: 10pt }
      .category { font-weight: bold; }
      td.category { font-style: italic }
      #bestinshow { color: red }
   </style>
...

Figure 5. The ID selector selects a specific element
id selectors



View Use Cascading Style Sheets Selectors Discussion

Page:  1 2 3 4 5 6 Next Page: Family relationships: descendants, children, and siblings

First published by IBM developerWorks


Copyright 2004-2017 GrindingGears.com. All rights reserved.
Article copyright and all rights retained by the author.