1. Home
  2. Computing & Technology
  3. Web Design / HTML

Advanced CSS
Font Properties

By , About.com Guide

There are many CSS properties to use in your style sheets. Here are some of the more popular properties and how to use them.

Font Properties

font-family - defines the font family that the text should be displayed in. (Note: if the computer viewing your page doesn't have the font specified, the browser will guess. This can cause strange effects. It is best to use standard fonts, or the generic font names.)

To define specific font families, write the family names in the order you would like them displayed (most accurate to your design first). Separate each family with a comma:

font-family : arial,geneva,helvetica,sans-serif;

To define a generic font family:

font-family : serif;
Generic font families allow the browser to choose the font most appropriate thatis included on the current system. These are:
  • serif
    font-family : serif;
  • sans-serif
    font-family : sans-serif;
  • monospace
    font-family : monospace;
  • cursive
    font-family : cursive;"
  • fantasy
    font-family : fantasy;

font-size - defines the size of the font. The font size can be specified as an exact size, a relative size, a length, or a percentage (of the existing space).

To define the exact size, simply specify the size in one of the following measurements:

  • ems
    font-size : 13em;
  • pixels
    font-size : 13px;
  • picas
    font-size : 13pc;
  • points
    font-size : 13pt;
  • inches
    font-size : 13in;
  • centimeters
    font-size : 13cm
  • milimeters
    font-size : 13mm

There are seven standard sizes in HTML and XML documents, you can define your font-size based on those sizes as well (standard text is size medium):

  • xx-small
    font-size : xx-small;
  • x-small
    font-size : x-small;
  • small
    font-size : small;
  • medium
    font-size : medium;
  • large
    font-size : large;
  • x-large
    font-size : x-large;
  • xx-large
    font-size : xx-large;

To define your font-size as relative to the surrounding text, you can simply say:

    font-style - defines whether the font is italic, oblique, or normal.

    • italic
      font-style : italic;
    • oblique
      font-style : oblique;
    • normal (the default)
      font-style : normal;

    font-variant - defines whether the font is normal or small-caps.

    • small-caps
      font-variant : small-caps;
    • normal (the default)
      font-variant : normal;

    font-weight - defines how dark or light the text is.

    • bold
      font-weight : bold;
    • bolder
      font-weight : bolder;
    • lighter
      font-weight : lighter;
    • 100
      font-weight : 100;
    • 200
      font-weight : 200;
    • 300
      font-weight : 300;
    • 400
      font-weight : 400;
    • 500
      font-weight : 500;
    • 600
      font-weight : 600;
    • 700
      font-weight : 700;
    • 800
      font-weight : 800;
    • 900
      font-weight : 900;
    • normal (the default)
      font-weight : normal;

    Next page > Text Properties > Page 1, 2, 3

    Previous Features

    Explore Web Design / HTML
    About.com Special Features

    Holiday Central

    What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

    Family Tech Center

    Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

    1. Home
    2. Computing & Technology
    3. Web Design / HTML
    4. CSS
    5. Advanced CSS
    6. Advanced CSS - Font Properties>

    ©2009 About.com, a part of The New York Times Company.

    All rights reserved.