Style-Sheets
  Home arrow Style-Sheets arrow Page 5 - Understanding Style Sheets (Part 1)
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Rational Software Development Conference
 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

Understanding Style Sheets (Part 1)
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2000-09-27

    Table of Contents:
  • Understanding Style Sheets (Part 1)
  • Into The Light
  • More Pseudo-Gibberish
  • The Colour Of My Eyes
  • Playing With Type
  • Adding A Little Style

  • 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

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Understanding Style Sheets (Part 1) - Playing With Type
    (Page 5 of 6 )

    How about changing those fonts around a little? Well, CSS comes with a whole bunch of properties whose sole raison d'etre is to give you more control over typeface. The first of these is the "font-family" property, which allows you to specify the font to be used when rendering a particular block of text.

    <HTML>
    <HEAD>
    <STYLE TYPE="text/css">
    P {font-family: "Verdana"}
    </STYLE>
    </HEAD>

    <BODY>

    <P CLASS="question">
    Q. How many testers does it take to change a light bulb?
    <P CLASS="answer">
    A. We just noticed the room was dark; we don't actually fix the problem.

    </BODY>
    </HTML>

    You probably already know that if the font specified isn't available on the client computer, the browser will use the default font (usually Times New Roman). And here's where CSS scores over the <FONT> tag - it allows you to specify a list of alternative fonts in the style definition.

    P {font-family: "Verdana", "Arial", "Arial Black"} /* first try Verdana,
    then Arial, then Arial Black */

    You have the option of using a generic class of typeface - pick from "serif", "sans-serif", "monospace", "cursive" and "fantasy". Try it and see for yourself.

    P {font-family: serif} /* font of type "serif" */

    You also have a number of options when deciding font size, since the CSS "font-size" property allows you to specify the size of your typeface in a number of different ways.First, there are absolute sizes, which are usually one of the following seven values: "xx-small", "x-small", "small", "medium", "large", "x-large" and "xx-large". Try this example out to see how this works:

    <HTML>
    <HEAD>
    <STYLE TYPE="text/css">
    .question {font-size: xx-small}
    .answer {font-size: x-large}
    </STYLE>

    </HEAD>

    <BODY>

    <P CLASS="question">
    Q. How many testers does it take to change a light bulb?
    <P CLASS="answer">
    A. We just noticed the room was dark; we don't actually fix the problem.

    </BODY>
    </HTML>

    Next, there are relative sizes, which allow you to specify a font "larger" or "smaller" than the size of the surrounding text.

    .question {font-size: larger} /* font size larger than the parent element
    */

    .question {font-size: smaller} /* font size smaller than the parent element
    */

    You can also specify an actual size in terms of points or percentages, like this:

    .question {font-size: 16pt} /* font size is 16 points */

    .question {font-size: 300%} /* font size is three times larger than usual*/

    More Style-Sheets Articles
    More By icarus, (c) Melonfire


     

       

    STYLE-SHEETS ARTICLES

    - What is CSS?
    - The Power of CSS
    - Understanding Style Sheets (part 2)
    - Understanding Style Sheets (Part 1)

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




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