Style Sheets
  Home arrow Style Sheets arrow Learn CSS, part 2: Units of Measurement
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, part 2: Units of Measurement
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 20
    2005-05-23

    Table of Contents:
  • Learn CSS, part 2: Units of Measurement
  • Using Pixels
  • Using em and ex
  • Using Percentage
  • Using Absolute Measurement Units

  • 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, part 2: Units of Measurement


    (Page 1 of 5 )

    In this second article in a multi-part series covering Cascading Style Sheets (CSS), we will discuss units of measurement for establishing the size of certain elements in your Web page. You will learn the difference between absolute and relative units of measurement, and which ones are better to use for particular purposes.

    You have been introduced to CSS in the first article. Now we will discuss the basic concepts that you should understand in order to maximize your CSS use in your projects. In this article we discuss the CSS units of measurements and learn when to use them. I'm sure that after a few articles you will appreciate CSS, because there are many effects that you can create with CSS which you can't create with HTML.

    CSS supports the the following units to measure your markup elements:

    • Centimeters: abbreviated as (cm)
    • Inches: abbreviated as (in)
    • Millimeters: abbreviated as (mm)
    • Points: abbreviated as (pt), equal to 1/72 of one inch
    • Picas: abbreviated as (pc), equal to 1/6 of one inch
    • Pixels: abbreviated as (px)
    • x-Height: abbreviated as (ex)
    • (em)
    • Percentage

    As you can see, there are some commonly used units that you are no doubt familiar with, such as inches, centimeters and pixels, and some that you may not have seen before, such as ex and em. There are two types of measurement units in CSS, relative measurement units and absolute measurement units (which are colored in red in the above list). Absolute units are those units that maintain their length across browsers and screen solutions, because it's assumed (I will discuss why I'm saying it's "assumed" shortly) that one centimeter is one centimeter in all browsers, regardless of screen resolution. Relative units, on the other hand, as the name applies, depend on some other value, such as screen resolution. The question is, do you need to use relative units or absolute units in your websites? Let's examine the issue.

    More Style Sheets Articles
    More By Michael Youssef


       · It would have been worth noting in this article that absolute measurements in...
     

    STYLE SHEETS ARTICLES

    - Styling HTML Lists with CSS: Replacing Bulle...
    - Styling HTML Lists with CSS: Changing the Ap...
    - Styling HTML Lists with CSS: Manipulating Pa...
    - Styling HTML Lists with CSS: Specifying Pad...
    - Styling HTML Lists with CSS: Resetting Paddi...
    - Absolute Positioning in CSS: a Dynamic Menu
    - CSS Absolute Positioning: Creating a Quick S...
    - CSS: Building Tooltips with Absolute Positio...
    - Styling Pseudo Classes with the RGBA CSS3 Pr...
    - Controlling Overall Transparency of an HTML ...
    - Altering the Border Opacity of an HTML Eleme...
    - The RGBA CSS3 Property: an Overview
    - Using Span Tags to Include Logos in Web Pages
    - Using a Single H1 Element to Include Logos i...
    - Combining Divs and H1 Elements to Include Lo...







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