HTML Font Color Codes

Here is the HTML and CSS codes required to change font and text colors of a few words within a paragraph or div. The outdated font tag is not used here because it is no longer recommended. Instead, we will be using an inline container called the SPAN element.

HTML Code for Font Color

<span style="color: #FF0000">Text</span>

Output

Text

Assigning Font Color Classes

If you have an External Style Sheet, you can suggest style rules to the span by adding the CLASS attribute which will save typing in all the code every time you want to color some text.

Add Color Code To External Style Sheet

span.redtext {
color: #FF0000
}

Add Class Attribute To Span

<span class="redtext">Text</span>

Output

Text

Note: Name the class redtext anything you want.

Also, if you want to assign a class with red bolded text and yellow background, you could simply name it something like highlight. Example:

Add Code To External Style Sheet

span.highlight {
color: #FF0000;
font-weight: bold;
background-color: #FFFF00
}

Add Class To Span

<span class="highlight">Text</span>

Output

Text

Related Articles

Coloring Table Backgrounds With HTML And CSS
How to change table background colors with an inline style sheet.

100% Hand Coded Web Site. © 2008 HTML Color Names