CSS Length Units


CSS Tutorial  >  Length Units

Length units in CSS fall under two categories: relative units and absolute units.

Relative units include:

  • px: pixels
  • em: em
  • ex: height of letter x

    Absolute units include:

  • in: inches
  • cm: centimeters
  • mm: millimeters
  • pt: points, 1 pt = 1/72 in
  • pc: picas, 1 pc = 12 pt

    If no unit is specified, the default unit is px.

    Below are examples for each unit type:

    CSS DeclarationOutput

    p {font-size:9px;}

    Font Size 9px.

    p {font-size:3em;}

    Font Size 3em.

    p {font-size:3ex;}

    Font Size 3ex.

    p {font-size:0.2in;}

    Font Size 0.2 inch.

    p {font-size:0.5cm;}

    Font Size 0.5 cm.

    p {font-size:12mm;}

    Font Size 12 mm.

    p {font-size:24pt;}

    Font Size 24 pt.

    p {font-size:2pc;}

    Font Size 2 pc.

    The general recommendation is to use relative length units. This way, you allow the users to increase or decrease the font size as they please. Using absolute length units takes away this option.

    Next: CSS Box Model

    Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.



    More Tutorials:   SQL   PHP   HTML


    Copyright 2007-2009   1keydata.com   All Rights Reserved.   Privacy Policy  



  • CSS Tutorial
    CSS Syntax
    Apply CSS
    CSS Media Types
    CSS Cascade
    CSS Inheritance
    CSS Class ID
    CSS Div Span
    CSS Length Units

    CSS Box Model
    CSS Margin
    CSS Border
    CSS Padding
    CSS Background
      CSS Background-attachment
      CSS Background-color
      CSS Background-image
      CSS Background-position
      CSS Background-repeat
    CSS Color
    CSS Font
    CSS Link
    CSS List
    CSS Table
    CSS Position
      CSS Absolute
      CSS Relative
      CSS Fixed
      CSS Static
      CSS Top
      CSS Bottom
      CSS Left
      CSS Right
      CSS Overflow
      CSS Z-Index
    CSS Text
    CSS Float
    CSS Clear
    CSS Cursor
    CSS Wrap

    CSS Codes

    Resources

    CSS Tutorial German