Home » How to Change Font Size in Html

How to Change Font Size in Html

by Online Tutorials Library

How to Change Font Size in Html

In HTML, we can change the size of any text using the following different ways:

  1. Using HTML tag
  2. Using an Inline style attribute
  3. Using internal CSS

Using HTML tag

Note: HTML 5 does not support the Size attribute of font, so we have to use the inline style attribute and internal CSS options for changing the size of a text.

If we want to change the size of a text using Html tag which is to be displayed on a web page, we have to follow the steps which are given below. Using these steps, we can easily change the size of any text:

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the Html tag for changing the font size.

Step 2: Now, move the cursor at the starting of that text whose size we want to change. And then, type the Html <font> tag at that position.

Step 3: Then, we have to close the font tag at the end of the text whose size we want to change.

Step 4: Now, we have to add the attribute of the font tag whose name is “size”. So, type the Size attribute within the starting <font> tag. And, then we have to give the size which we want to use on the text. We can give the value of size from 1 to 7. So, type the number in the Size attribute as described in the following block.

Step 5: And, at last, we have to save the Html code in the text editor and run the code. After executing, we will see the output in the browser. The following screenshot shows the output of the above Html Code:

How to Change Font Size in Html

Using an Inline Style attribute

If we want to change the size of a text using an inline style attribute which is to be displayed on a web page, we have to follow the steps which are given below. Using these steps, we can easily change the text size.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the style attribute for changing the size of a text.

Step 2: Now, place the cursor at the starting of that text whose size we want to change. And then, type the inline style attribute within any element. Here, we use the <p> (paragraph) tag:

Step 3: In this step, we have to give the size. So, type the size in the font-size property of the style attribute.

Step 4: Then, we have to close the element at the end of the text whose size we want to change.

Step 5: And, at last, save the Html code which changes the text/font size using the CSS style attribute.

Test it Now

The output of the above code is shown in the following screenshot:

How to Change Font Size in Html

Using Internal CSS

If we want to change the text or font size using an internal cascading stylesheet which is to be displayed on a web page, we have to follow the steps which are given below. Using these steps, we can easily change the size of any text.

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the internal CSS for changing the size of a text.

Step 2: Now, we have to place the cursor in the head tag of the Html document and then define the styles inside the <style> tag as shown in the following block. And, then type the font-size attribute into the element selector.

Step 3: Now, we have to type the defined element selector before the text whose size we want to change.

Test it Now

The output of the above code is shown in the following screenshot:

How to Change Font Size in Html


You may also like