This article was co-authored by wikiHow staff writer, Hannah Dillon. Hannah Dillon is a Technology Writer and Editor at wikiHow. She graduated with a B.A. in Journalism from North Dakota State University in 2013 and has since worked in the video game industry as well as a few newspapers. From a young age Hannah has cultivated a love for writing and technology, and hopes to use these passions in tandem to help others in the articles she writes for wikiHow.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 638,836 times.
Learn more...
This wikiHow teaches you how to change font color in your HTML document. While the HTML font tag is obsolete in HTML5, you can use CSS to add color to your HTML page's text. If you're working with an older version of HTML, you can use the HTML font color tag as needed.
Changing Font Color in HTML
The only way to change font color in HTML is to use another language called CSS. The font color tag is obsolete in HTML5. However, if you are working with an older version of HTML, the tag should still work.
Steps
Using CSS Classes
-
Pick a color for your text. While you can use basic colors (e.g., "red") to color your text, you'll need to use hex codes for more nuanced shades:
- Go to w3school's hex code list in your computer's web browser.
- Select the base color you want to use in the hexagon at the top of the page.
- Scroll to the shade you want to use on the right side of the page.
- Note the six-character code to the right of the shade. Make sure to include the hashtag (#) when copying the color.
-
Open your HTML document. This should be the document for which you want to change the font color.
- If you don't yet have an HTML document, create one before proceeding.
Advertisement -
Find the text you want to color. Scroll through your document until you find the paragraph, header, or other form of text that you want to color.
-
Note the text's tags. For example, if the text is a header, you'll see "<h1>" in front of it.
- If the code doesn't have a container tag, you'll have to add one yourself. You can do this by wrapping the text in
tags. Placeafter the text.before the text, and
- If the code doesn't have a container tag, you'll have to add one yourself. You can do this by wrapping the text in
-
Add the "head" and "style" sections to the top of the document. You'll do this by typing <head> below the "<html>" tag, pressing ↵ Enter, typing <style> below the "<head>" tag, pressing ↵ Enter twice, and typing in the closing tags for both. Your end result should look like this:
<!DOCTYPE html> <html> <head> <style> </style> </head> <body>
-
Enter the "color" style tag. Click the space between the "<style></style>" tags, then enter the following code (making sure to replace red with your hex code and "h1" with the tag for the text you want to color).
h1 { color: red; }
- If you had to add your own container tag, give the container a class. Make sure it's a unique class name that isn't used anywhere else in the document. For example, you could name the class "text-color." Place that class between the quotation marks in <div class=""></div>.
- Then, when adding the CSS code, follow the steps above. However, instead of writing "h1," write .text-color. Make sure to include the leading period, or the code won't understand that you're referencing the text-color CSS class you created.
-
Review your document. Your page header should look something like this:
<!DOCTYPE html> <html> <head> <style> h1 { color: red; } </style> </head> <body> </body>
-
Unify the body text color. If you want to make all of your document's body text the same color, enter the following code with your preferred color substituted for black:
body { color: black; }
Using Inline CSS
-
Pick a color for your text. While you can use basic colors (e.g., "red") to color your text, you'll need to use hex codes for more nuanced shades:
- Go to w3school's hex code list in your computer's web browser.
- Select the base color you want to use in the hexagon at the top of the page.
- Scroll to the shade you want to use on the right side of the page.
- Note the six-character code to the right of the shade. Make sure to include the hashtag (#) when copying the color.
-
Open your HTML document. This should be the document for which you want to change the font color.
- If you don't yet have an HTML document, create one before proceeding.
-
Find the text you want to color. Scroll through your document until you find the paragraph, header, or other form of text that you want to color.
-
Locate the opening container tag. If the code doesn't have a container tag, you'll have to add one yourself. You can do this by wrapping the text in <div></div> tags. Place <div> before the text, and </div> after the text.
-
Add the "style" attribute. To do this, add style="" to your opening tag. If you're editing an <h1> tag, the opening tag will look like <h1 style="">. If you're editing a <div> tag, the opening tag will look like <div style="">.
-
Add your inline CSS. To change the color of your text, you'll use the "color" property. Here's what your code should look like after you've added the inline CSS (making sure to replace "red" with the hex code you want to use):
<!DOCTYPE html> <html> <head> </head> <body> <h1 style="color: red;">Header here</h1> </body>
Using HTML Tags
-
Pick a color for your text. While you can use basic colors (e.g., "red") to color your text, you'll need to use a hex code list for more nuanced shades:
- Go to w3school's hex code list in your computer's web browser.
- Select the base color you want to use in the hexagon at the top of the page.
- Scroll to the shade you want to use on the right side of the page.
- Note the six-character code to the right of the shade. Make sure to include the hashtag (#) when copying the color.
-
Open your HTML document. This should be the document you want to change the font color in.
- If you don't yet have an HTML document, create one before proceeding.
-
Find the text you want to color. Scroll through your document until you find the paragraph, header, or other form of text that you want to color.
-
Add the open "font" tag. Click immediately left of the text you want to color, then type in the following (making sure to replace red with your preferred hex code):[1]
<font color="red">
-
Close the "font" tag. Click the space to the right of the end of the text you're coloring, then type </font> there.
<font color="red">This text is red!</font>
Sample HTML Code
Community Q&A
-
QuestionHow do I use a color codes?
Community AnswerYou can use hex codes (e.g. #ff00ff), rgb codes (e.g. rgb(255,100,309) ), or web safe colors (colors that are just their name like 'red' or 'black'). You can use colorhexa.com to get color codes. -
QuestionHow do I change color:red to color:blue?
Community AnswerAs long as you are using a normal editor such as notepad, you can just go in and replace the word 'red' with the word 'blue'.
Video
Tips
-
Old computer displays are limited to about 65,000 colors, and very old displays are limited to 256. However, over 99% of internet users will be able to see any color you specify.[2]Thanks
-
Hex codes are broken up as follows: the first two characters refer to red hues, the second two refer to green, and the last two refer to blue. You can use anything from "00" to "99" to indicate how much of each color you want; using "FF" instead of a number calls the maximum amount of that color (for example, "0000FF" would be as blue as possible).Thanks
-
Try to make your page easy to read. Bright colors are hard to read on a white background, and dark colors are hard to read on a black background.Thanks
Warnings
- The font element is not supported in XHTML 1.0 Strict DTD.Thanks
References
About This Article
1. Select a color.
2. Find the code for the color.
3. Open the HTML code.
4. Find the tag for the text you want to color.
5. Enter the "color" style for that tag.
6. Unify the body text color.
Reader Success Stories
-
"Really good explanations of each step in the tutorials makes it so much easier for people like me who are just beginning to learn any type of computer language."..." more




















