Setting the Font Style and Weight

The font-weight property sets the weight of the font. It increases the weight makes the text bolder.

The font-style property selects between normal, italic, and oblique fonts.

 
<!DOCTYPE HTML> 
<html> 
    <head> 
        <title>Example</title> 
        <style> 
            p { 
                padding: 5px; 
                border: medium double black; 
                background-color: lightgrey; 
                margin: 2px; 
                float: left; 
                font-family: sans-serif; 
                font-size: medium; 
            } 
            #first { 
                font-weight: bold; 
            } 
            #second { 
                font-style: italic; 
            } 
        </style> 
    </head> 
    <body> 
        <p> 
            <span id="first">CSS</span> 
            <span id="second">HTML</span>
        </p> 
    </body> 
</html>
  
Click to view the demo
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: