Style Sheets
  Home arrow Style Sheets arrow Page 6 - Learn CSS, part 1
IBM developerWorks
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  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 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, part 1
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 30
    2005-05-16

    Table of Contents:
  • Learn CSS, part 1
  • CSS Specifications and Implementations
  • Browsers we are going to use
  • The HTML vs. CSS example
  • CSS rules and selectors
  • Groups of Selectors
  • Validating your CSS Documents

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Learn CSS, part 1 - Groups of Selectors


    (Page 6 of 7 )

    As we said, CSS is a powerful but simple language, and you will be amazed with what you can do with it. Let's extend our paragraph example a little more. Suppose that we also need to apply an Arial font with a red color to hyperlink references in our website. We may write another CSS rule like this:

    a
    {
    font-family: Arial, sans-serif;
    color: red;
    }

    so the Paragraph.css file has two CSS rules:

    p
    {
    font-family: Arial, sans-serif;
    color: red;
    }

    a
    {
    font-family: Arial, sans-serif;
    color: red;
    }

    Now you can add a hyperlink reference to your HTML page:

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link rel="stylesheet" href="paragraph.css" type="text/css">
    <title>The IT Field</title>
    </head>
    <body>
    <p>
    Information Technology (IT) has been the most famous and attractive field in the last
    20 years and many students choose to study Computer Science and Information System which qualify
    them to work as Programmers, Developers, Database Administrators and Network Engineers.
    </p>
    To read more about IT please<a href="http://www.it.com">Click Here</a>
    </body>
    </html>

    There's a better way to achieve the same effect: group the selectors. Modify the CSS file to be as follows:

    p, a
    {
    font-family: Arial, sans-serif;
    color: red;
    }

    Reopen the web page and you will have the same effect. But this grouping technique is better because you don't write a separate rule and declarations for a selector. You just put in as many selectors as you want and separate each of them using a comma.

    More Style Sheets Articles
    More By Michael Youssef


       · Pretty basic stuff; certainly not bad, though.You can find another (slightly...
       · Hello, I have wrote 10 articles in my Learn CSS Series and most of them have...
       · I have written the following articles in the CSS series in the following order1-...
       · As strictly a web designer (not coder!) that relied on Dreamweaver/HTML for small...
       · W3 is strictly show-and-tell. It doesn't explain the concepts presented. Units of...
     

    STYLE SHEETS ARTICLES

    - Creating Gradients for Individual Containers...
    - Creating Gradients for Web Page Headers with...
    - SEO Scrolling Frames Problem Solved
    - Building Cross-Browser Background Effects wi...
    - CSS: Pseudo
    - Using PNG Images to Build Background Effects
    - CSS: Continuing the Clarification of CSS Cla...
    - CSS: Top Secret Classification
    - CSS: Dimensions
    - CSS: Margins and Padding
    - CSS: Crossing the Border
    - CSS: Text, Fonts, and Tables
    - CSS: Working with Text
    - CSS: Backgrounds
    - CSS for the Newbie







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway