Skip to content
Related Articles

Related Articles

Improve Article

How to change font size in HTML ?

  • Last Updated : 22 Mar, 2021

To change the font size of any text we can use the CSS font-size Property, or some HTML keyword have some fixed font size but we change them as well by using this CSS property.

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
        <title
            CSS font-size property 
        </title
          
        <!-- CSS style to set font-size property -->
        <style
            .xxsmall { 
                font-size:xx-small; 
            
            .xsmall { 
                font-size:x-small; 
            
            .small { 
                font-size:small; 
            
            .medium { 
                font-size:medium; 
            
            .large { 
                font-size:large; 
            
            .xlarge { 
                font-size:x-large; 
            
            .xxlarge { 
                font-size:xx-large; 
            
        </style
    </head
      
    <body
        <h1>Changing the Font Size</h1
          
        <div class = "xxsmall">font-size: xx-small;</div
        <div class = "xsmall">font-size: x-small;</div
        <div class = "small">font-size: small;</div
        <div class = "medium">font-size: medium;</div
        <div class = "large">font-size: large;</div
        <div class = "xlarge">font-size: x-large;</div
        <div class = "xxlarge">font-size: xx-large;</div
    </body
</html>

Output:

font size

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :