In this tutorial we will teach you the ways of changing text color in HTML. Changing color of the text in HTML can be done in many ways. One way is to set s universal color for the whole text and the other way is to use a color for a specific attribute. Overall, there are 16 million colors of HTML with their 6-digit hex codes which are easily available on the internet.
Step 1: Set Universal Color of the Text in HTML
In html, to change text color you can set the universal color. Setting universal color means to set a color for all attributes of text like heading, paragraph etc in the body element. To set the color, you can use any of the 6-digit code for the color value or simply write the name of the color, for example orange or any other, along with the text. This will change all the text on a web page to orange. Similarly, by setting the text attribute to blue, the text color of the web page changes to blue..
Step 2: Change Text color of a paragraph in HTML
If we don’t want to change the color of the complete text on the webpage, we can use the “font” element for changing text color in html. We have to first set the color value inside the font element. The color value can be set by any of the 6-digit Hex code or writing only the color name. The text has to be placed within the font element. Over here, let’s set the color to green and once your refresh the page, you can see that html changes the text color.
Step 3: Change Line’s Text color in HTML
In order to change the color of a single line, we enclose the text within the text color attribute and set the color to the desired color. This change is specific to a piece of text and overrules any text color set at the universal level or to the paragraph containing the line.