How to change the font size in HTML

Font size in HTML

In HTML the method of changing a font size is pretty simple and easy. All you have to do is include the tag in the code snippet below.

<html>
 <head>
 </head>
 <body>
   <font size="number">text</font>
 </body>
</html>

The size number must be in " ". However, keep in mind that this only works for versions before HTML 5. Let’s look at an example before we move on to changing font sizes in HTML 5.

<html>
 <head>
 </head>
 <body>
   <p><font size="6">Font size is 6</font></p>
   <p><font size="24">Font size is 24</font></p>
 </body>
</html>

Font size in HTML 5 and onwards

In HTML 5 the syntax changes. For this, the font size is changed using the CSS font-size property where the tag changes slightly. This is shown in the code snippet below.

<html>
 <head>
 </head>
 <body>
   <p style="font-size:numberpx">text</p>
 </body>
</html>

Let’s look at an example below to better understand this.

<html>
 <head>
 </head>
 <body>
   <p style="font-size:10px">Font size is 10px</p>
   <p style="font-size:30px">Font size is 30px</p>
 </body>
</html>

Leave a Reply