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 
Sun Developer Network 
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 / 3
    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

    - Improving the Visual Presentation of a CSS D...
    - Fixing Browser Incompatibilities in a CSS Dr...
    - Building Clean Drop-Down Menus with CSS
    - Creating Hybrid Web Page Layouts with Negati...
    - Creating Three-Column Web Page Layous with N...
    - Swapping Column Positions in Web Page Layout...
    - Creating Web Page Layouts with Negative Marg...
    - 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






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT