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





    Copyright 1keydata.com 2007, 2008, 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 Color
    CSS Font
    CSS Link
    CSS List
    CSS Table
    CSS Position
    CSS Text
    CSS Float
    CSS Clear
    CSS Cursor

    CSS Codes

    Resources