In our previous tutorials you have learned about heading , paragraph , italic , bold , underline text etc. In this tutorial you will learn how we can change size and color of the fonts/text in HTML web page but before we start let’s learn something about attributes.
What is an attribute ?
Attributes provide additional information about the contents of an element. It can also enhance the ability of an HTML element/tag. An attribute consists of two parts First is the name of the attribute and the second is the value of the attribute. Attribute comes inside the opening tag.
Syntax of Attribute in HTML
<body attribute_name = “ attribute_value” >
This is how we write an attribute in HTML. It will be easy to understand for you when you will see some examples.
Changing the font color in html
To change the font color we use < font > tag but only font tag will not do the job. An attribute “color” is used to change the font color.
<font color=”red”> This text will be appeared in red. </font>
Example of Changing color in HTML
Changing the font size in HTML
In order to have text in different size use < font > tag with an attribute “size” . You can put any value in size attribute as you want. In example we use 10 but you can try with any value bigger or smaller than this.
Syntax of changing the font size HTML
<font size = “10”> This text is larger than normal text </font>
Example of changing text in HTML
Combining both attributes size and color
You can combine both attribute in a single font tag. See example
<font size =”10” color=”blue”> This text is effected by both attribute </font>