Open In App

CSS font-weight Property

The font-weight property of the CSS is used to set the weight or thickness of the font being used with the HTML Text. The font-weight applied will depend on font-family used and the browser. For instance, some font-family is available only in specific weights.

Syntax:



font-weight: normal|bold|lighter|bolder|number|initial|inherit|unset;

Property Values:

Global Values:



When lighter or bolder is specified, the below chart shows how the absolute font-weight of the element is determined.

Parent Value

lighter

bolder

100

100

400

200

100

400

300

100

400

400

100

700

500

100

700

600

400

900

700

400

900

800

700

900

900

700

900

Example: The following example demonstrates the use of CSS font-weight property in which the property has been set to different values.




<!DOCTYPE html>
<html>
<head>
    <title> font-weight property </title>
    <!-- font-weight CSS property -->
    <style>
    body {
        font-weight: bold;
        font-family: sans-serif;
    }
      
    p.one {
        font-weight: bold;
    }
      
    p.two {
        font-weight: lighter;
    }
      
    p.three {
        font-weight: 1000;
    }
      
    p.four {
        font-weight: initial;
    }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
    <h3>CSS font-weight Property</h3>
    
    <!-- font-weight: bold; length; property -->
    <p class="one"
       Prepare for the Recruitment drive of product based 
       companies like Microsoft, Amazon, Adobe etc with a 
      free online placement preparation course. 
      The course focuses on various MCQ's & Coding 
      question likely to be asked in the interviews 
      & make your upcoming placement season efficient 
      and successful. 
    </p>
  
    
    <!-- font-weight: lighter; length; property -->
    <p class="two"
      Prepare for the Recruitment drive of product based 
      companies like Microsoft, Amazon, Adobe etc with a 
      free online placement preparation course. The course 
      focuses on various MCQ's & Coding question likely to
      be asked in the interviews & make your upcoming 
      placement season efficient and successful. 
    </p>
  
    
    <!-- font-weight: 1000; length; property -->
    <p class="three"
      Prepare for the Recruitment drive of product based 
      companies like Microsoft, Amazon, Adobe etc with 
      a free online placement preparation course. The 
      course focuses on various MCQ's & Coding question 
      likely to be asked in the interviews & make your 
      upcoming placement season efficient and successful. 
    </p>
  
    
    <!-- font-weight: initial; length; property -->
    <p class="four"
      Prepare for the Recruitment drive of product based 
      companies like Microsoft, Amazon, Adobe etc with a 
      free online placement preparation course. The course 
      focuses on various MCQ's & Coding question likely to 
      be asked in the interviews & make your upcoming 
      placement season efficient and successful. 
    </p>
  
</body>
</html>

Output:

Supported Browsers: The browser supported by CSS font-weight Property are listed below:


Article Tags :