Style Sheets
  Home arrow Style Sheets arrow Page 3 - The Advantages of Style Sheets
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

The Advantages of Style Sheets
By: Stephen Davies
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2007-08-07

    Table of Contents:
  • The Advantages of Style Sheets
  • Inline and External Styles
  • The CLASS and ID tags
  • Final Working Examples

  • 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


    The Advantages of Style Sheets - The CLASS and ID tags


    (Page 3 of 4 )

    As shown briefly earlier, style sheet properties can be specified according to the tag -- P, H1, FONT, etc. This is the power of style sheets in styling the page as a seamless process. We can apply a variety of different classes to various tags. Using the internal style sheet example:

    <HEAD>
     
    <TITLE>Change the paragraph colour and size</TITLE>
     
    <STYLE TYPE="text/css">
       
    P.colorchoice1 { font-size: 3; color: blue; }
       
    P.colorchoice2 { font-size: 3; color: red; }
     
    </STYLE>
    </HEAD>

    This is the same as the example on the first page of this article except that it can set two different colors for the <P> tag lines in the HTML code. They keep the font type and size the same but apply two different colors -- blue and red. Any different style can be applied to the same tag as shown above. Remember that hex values can be applied here too; for example, red would be #990000.

    On the first page, it was briefly explained how to apply class names. For the example above, the P tag can be given the two color properties like this:

    <p class="colorchoice1">
      The text is blue
    </p><br>
    <p class="colorchoice2">
      The text is red
    </p>

    The resulting displayed text would be:

    The text is blue

    The text is red

    You can also use the ID selector to define any styles for the HTML code. This is done via the # symbol. Looking at the example above:

    <HEAD>
      <TITLE>Change the paragraph colour and size</TITLE>
      <STYLE TYPE="text/css">
       
    p#colorchoice1 { font-size: 3; color: blue; }
       
    p#colorchoice2 { font-size: 3; color: red; }
     
    </STYLE>
    </HEAD>

    The HTML display will show the page text that uses the ID of colorchoice1 or colorchoice2. So in the main body of the HTML code:

    <p id="colorchoice1">
      The text is blue
    </p><br>
    <p id="colorchoice2">
      The text is red
    </p>

    The ID selector can be left as a single property and used for any of the HTML tags again simply by omitting the tag specification:

    #blue {color: blue}

    More Style Sheets Articles
    More By Stephen Davies


       · This taster on style sheets should be helpful to those starting out on style sheets....
     

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek