Style Sheets
  Home arrow Style Sheets arrow Page 4 - Learn CSS, Selectors
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
STYLE SHEETS

Learn CSS, Selectors
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 22
    2005-06-06

    Table of Contents:
  • Learn CSS, Selectors
  • The Universal Selector
  • The Class Selector
  • The ID Selector

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Learn CSS, Selectors - The ID Selector


    (Page 4 of 4 )

    There's a big difference between the HTML class attribute and the ID attribute. The first difference is that the class attribute in HTML means that this element has a classification. In other words, this element has a class of NavyArial, which as we know defines a Navy text, Arial and .8em font-size. You can use this class as value to any element in the document, but ID does not work like this.

    Actually, the term ID means identifier so, for example, your ID is your Social Security number -- this number is only yours and we can't find someone else who has the same number. In HTML the attribute ID's value is set once for each element, and it must be unique in the document. This is an obvious different between the class selector and the ID selector. The value of the ID attribute doesn't permit any white spaces, so we can't combine ID selectors as we did with class selectors. If you have used the same ID value for more than one element, web browsers will apply the styles for the elements, although this is far from what should happen.

    To create an ID selector, use the hash mark (#) instead of the dot (.) and you are done, but you must set the value of the HTML ID attribute to the ID selector name. Here is an example:

    h1,p
    {
      color: blue;
      font-family: Arial;
    }
    h1
    {
      background-color: GreenYellow;
      font-size: 1.3em;
    }
    p
    {
      font-size: .9em;
    }
    #OrderedList
    {
      color: navy;
      font-family: Arial;
      font-size: .8em;
    }

    Now you need to modify the HTML code, remove the class attribute of the <ol> element and put the ID attribute to be the following:

    <ol ID="OrderedList">

    Note that we didn't include the # in the name of the ID selector, in much the same way we didn't include the dot (.) in the name of the class selector.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · At last, someone who describes the process in plain and simple English. I am so...
     

    STYLE SHEETS ARTICLES

    - Image Replacement CSS Techniques
    - Using BlueTrip`s Success, Notice and Error C...
    - More Uses for the Thin and Caps CSS Classes ...
    - Styling Definition Lists with the BlueTrip C...
    - Styling Unordered and Ordered HTML Lists wit...
    - Using the BlueTrip CSS Framework`s Thin and ...
    - Adding Borders to Web Page Columns with Blue...
    - Introducing the BlueTrip CSS Framework
    - Using a Background Grid to Assist Web Page L...
    - Extending the Rule Of Thirds for Web Page La...
    - A Two-Column Web Page Layout Based on the Ru...
    - Using the Rule Of Thirds for Web Page Layout
    - Swapping Columns Using the Divine Ratio for ...
    - Using the Golden Ratio in Liquid Web Page De...
    - Fundamental Design Principles for Web Page L...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek