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 © 2021   1keydata.com   All Rights Reserved   Privacy Policy   About   Contact
  • 老湿机69福利区无码_老子影院午夜伦无码_开心亚洲五月丁香五月