How to change text color using <font> tag
The <font> tag is used to change not only the text color but also the font size and the font face. This tag was used in previous versions of HTML and is depleted from HTML5. This is because using this tag makes the procedure of styling elements hectic. You have to specify this tag for every element for every other web page.
HTML
In the above code, we have defined an <h1> and <p> element and using the <font> tag the text color of the heading has been set to red, meanwhile, the text color of the paragraph is assigned blue color.
Output
The color of the text was changed successfully.
How to change text color using the style attribute
The approach that is preferred over using the <font> tag is the usage of the style attribute. This method is shown in the code given below.
HTML
In the code snippet above, we are using the style attribute of each of the elements generated above. Using this attribute the text color of the heading was set to purple, whereas, the paragraph was given a red text color. This attribute gives an inline style to elements.
Output
The style attribute is working properly.
Following the approaches mentioned above, you can easily change the text color in HTML.
Conclusion
In order to change the text color in HTML either use the <font> tag or use the style attribute. The <font> tag is, however, deleted from HTML5 because using this tag makes the procedure of styling elements hectic. You have to specify this tag for every element for every other web page. Meanwhile, the style attribute gives an inline style to elements, therefore, this approach is preferred over the former.