Search code examples
htmlcssfontssize

Font size not changing in HTML


So, after I tried all the answers in the forums over here, the font size of my webpage won't change. Here's what I currently have: <font size="40px" face="Didot">Hello</font> Okay, it will set to 40px, but if I try to make another one using 20px it won't change the font size: <font size="20px" face="Didot">World</font>
Whole code for those who want to check for themselves

<html>
<font size="40px" face="Didot">Hello</font>
<font size="20px" face="Didot">World</font>
</html>

Solution

  • <font> tag is deprecated. ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font )

    Use CSS styling instead. See the example below.

    .size40 {
      font: 40px/1.5 Didot, serif;
    }
    
    .size20 {
      font: 20px/1.5 Didot, serif;
    }
    <span class="size40">Hello</span>
    <span class="size20">World</span>