Skip to content
Related Articles

Related Articles

How to change font size using CSS ?
  • Difficulty Level : Medium
  • Last Updated : 25 Mar, 2021

The purpose of this article is to change font-size using CSS.

The font-size CSS property sets the size of the font. There are several ways to specify the font size, including keywords or numerical values for pixels or ems. Choose the appropriate method based on the needs of the particular web page. 

Syntax :

font-size: medium|xx-small|x-small|small|large|x-large
|xx-large|smaller|larger|length|initial|inherit;

Example:

HTML




<!DOCTYPE html>
<html>
  <head>
    <style>
      .div1 {
        font-size: 1.2em;
      }
      .div2 {
        font-size: smaller;
      }
      .div3 {
        font-size: 80%;
      }
      .div4 {
        font-size: 12px;
      }
      .div5 {
        font-size: x-small;
      }
    </style>
  </head>
  <body>
    <div class="div1">GeeksforGeeks</div>
    <div class="div2">GeeksforGeeks</div>
    <div class="div3">GeeksforGeeks</div>
    <div class="div4">GeeksforGeeks</div>
    <div class="div5">GeeksforGeeks</div>
  </body>
</html>

Output:

different font size 

My Personal Notes arrow_drop_up
Recommended Articles
Page :