Using Web Fonts

You can't rely on the font you want to be installed on the user's machine. With use web fonts, you can download a font and use it on your page without requiring any user interaction.

You specify web fonts using @font-face. There are a lot of web font resources available. You can see the fonts at www.google.com/webfonts.

 
<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
        <style> 
            @font-face { 
                font-family: 'MyFont'; 
                font-style: normal; 
                font-weight: normal; 
                src: url('http://yourServer/listings/MyFont.woff'); 
            } 
            p { 
                padding: 5px; 
                border: medium double black; 
                background-color: lightgrey; 
                margin: 2px; 
                float: left; 
                font-size: medium; 
                font-family: MyFont, cursive; 
            } 
            #first { 
                font-weight: bold; 
            } 
            #second { 
                font-style: italic; 
            } 
        </style> 
    </head> 
    <body> 
        <p> 
            <span id="first">HTML</span>
            <span id="second">CSS</span>
        </p> 
    </body> 
</html>
  
Home 
  HTML CSS Book 
    CSS  

Font:
  1. Font-related properties
  2. Selecting a Font with font-family
  3. Setting the Font Size
  4. Setting the Font Style and Weight
  5. Using Web Fonts
Related: