Make Your Text Any Color: The Complete HTML Font Color Playbook

how to change font color in html css

Written by

in

0 / 2000

Everything uses Unicode characters only. Free, no app or sign up needed.

Copied

One line of CSS is all it takes to turn black text blue, red, or any of 16 million colors. If you are learning how to change font color in HTML, this guide gives you the three methods, the five ways to write a color, and the mistakes to skip, with code you can copy straight into your own page.

how to change font color in html css

The short version: the CSS color property does the work, and the old font tag does not belong in your code anymore. Where you put that one line depends on whether you are styling one word, one page, or a whole website, and this guide takes the three cases in that order.

The One Line That Changes Any Text Color

Every method in this guide comes down to the same CSS property: color. Point it at an element, give it a value, and the browser paints the text. Here is the rule in its simplest form:

p {
  color: #1a73e8;
}

That rule turns every paragraph on the page blue. To color just one paragraph, put the same property inside the tag itself, as an inline style:

<p style="color: #1a73e8;">This paragraph is blue.</p>

That is the whole secret behind how to change font color in HTML. Everything else is choosing where that line lives and which color value to write, and both choices have a right answer for each situation.

Pick Your Method: Quick Fix, One Page, or Whole Site

There are three places to put your color rules, and the right one depends on how much of your site you are styling. Pick the row that matches your project:

MethodWhere the code livesBest forWatch out for
Inlinestyle attribute on one tagOne-off fixes, tests, email templatesRepeating it gets messy fast
Internalstyle block in the page headSingle pages, landing pages, practiceMust be copied to every page
ExternalA separate .css file, linked onceReal websites with many pagesBrowser cache can hide your edits

Inline is the fastest way to learn how to change font color in HTML, because you see the result in seconds and nothing else is involved. Internal is the cleanest way to style one page, because one block in the head colors every heading and paragraph at once. External is the professional default: one stylesheet controls the whole site, so changing your brand color means editing one file, not fifty pages.

If you are not sure which to pick, start internal. You can move the same rules into an external file later without changing a single color value.

5 Ways to Write a Color in CSS

CSS accepts a color in five formats. They all paint the same text, but each one is useful in a different moment:

  • Names: plain words like red, navy, and tomato. About 140 are built into CSS. Great for practice, too vague for brand work.
  • HEX: a hash plus six digits, like #80065f. The first pair is red, the second green, the third blue. #333 is shorthand for #333333. This is the format design tools copy, so it is the one you will use most.
  • RGB: three numbers from 0 to 255, like rgb(128, 6, 95). Add a fourth number for transparency: rgba(128, 6, 95, 0.5) is the same color at half strength.
  • HSL: hue, saturation, lightness, like hsl(315, 92%, 26%). Designers love it because raising the lightness makes a lighter shade without guessing new numbers.
  • Variables: name your color once, then reuse it everywhere. Define it at the top of your stylesheet and every heading, link, and button can share it.
:root {
  --brand: #80065f;
}
h1 {
  color: var(--brand);
}
a {
  color: var(--brand);
}

Variables are the format beginners skip and professionals rely on. Change –brand once and every element using it updates together, which is exactly what you want when a client asks for a different shade of purple at the last minute. Once you know these five formats, how to change font color in HTML becomes a one-line decision: pick the method, pick the format, write the rule.

The Dead Tag: Why the Old Font Tag Belongs in History

Old tutorials still show the font tag, and it still works in most browsers today. Do not use it. It was deprecated in HTML 4.01 back in 1999 and removed from the HTML5 standard entirely, which means browsers keep it only as a favor to ancient pages. It is the one method for how to change font color in HTML that you should actively unlearn.

<font color="red">This text is red.</font>

That line has three problems. It mixes styling into your content, so a redesign means editing every page by hand. It cannot do anything else: no hover states, no responsive changes, no shared styles. And it teaches a habit that breaks the moment you touch a modern framework or a WordPress theme.

The modern version of the same line is shorter and does more:

<p style="color: red;">This text is red.</p>

Same result, but now the color lives in CSS, where it belongs. If you inherit a page full of font tags, replace them with classes one section at a time instead of rewriting the whole page in one sitting.

Name Colors by Their Job, Not Their Shade

Classes are where color stops being decoration and starts being a system. Instead of coloring each paragraph by hand, give the color a name that explains its purpose, then reuse that name everywhere the same meaning appears:

.success {
  color: #15803d;
}
.warning {
  color: #b45309;
}
.error {
  color: #b91c1c;
}
.muted {
  color: #6b7280;
}

The names matter more than the shades. A class called success still makes sense if you later change green to blue, but a class called green-text becomes a lie the moment you change it. Name the job, not the color.

This habit pays off the first time you redesign. When success, warning, and error each live in one class, a full color change is four lines of CSS. When the same colors are scattered through inline styles, it is an afternoon of searching. That is the difference between knowing how to change font color in HTML and knowing how to manage it.

Readable First: Contrast Rules That Keep Text Legible

A beautiful color that nobody can read is a failed color. The web accessibility standard, WCAG, sets two numbers worth memorizing: normal text needs a contrast ratio of at least 4.5 to 1 against its background, and large text needs at least 3 to 1. Dark gray on white passes easily. Light gray on white does not, no matter how elegant it looks in your design tool.

Three habits keep your text readable. First, test on a phone in bright daylight, because a color that looks strong on your desk monitor can vanish outdoors. Second, never use color as the only signal: an error message should say it is an error in words, not just in red, because some readers cannot tell red from green. Third, keep body text near black or dark gray and save bright colors for short labels, links, and buttons, where they guide the eye instead of tiring it.

Contrast checkers are free and take ten seconds. Run your two main colors through one before you publish, and you will never have to guess whether your text is readable. That is the part of how to change font color in HTML that most tutorials skip: the color is easy, the readability is the skill.

Color Recipes for Real Pages

Here are four ready to use recipes that put how to change font color in HTML into practice for the places where color matters most. Copy them, change the values to your brand, and you have a working color system:

body {
  color: #1f2937;
}
h1, h2 {
  color: #111827;
}
a {
  color: #1a73e8;
}
a:hover {
  color: #0b57d0;
}
.alert {
  color: #b91c1c;
}

Notice what the recipes do not do. Links get their own color and a darker hover shade, so readers always know what they can click. Headings are only slightly darker than body text, because hierarchy comes from size and weight, not from a rainbow. And the alert color appears once, for one job.

Color works best when it supports the font, not when it fights it. Try your exact headline in the font generator at the top of this page first, then pick a color that suits the style you chose. A playful style wants a warm color; a formal style wants a deep one. And if you are styling text for a profile instead of a page, our Instagram fonts page has ready made styles you can pair with any color.

7 Color Mistakes That Make Pages Look Amateur

These seven mistakes show up on beginner pages again and again, even from people who already know how to change font color in HTML. They are all easy to fix once you know they exist:

  • Using the dead font tag: it is obsolete, and every modern tutorial has moved on. Use CSS.
  • Inline styles everywhere: one or two are fine. Fifty of them means your next redesign is a manual search through every page.
  • Too many colors: four purposeful colors look designed. Ten random shades look like an accident.
  • Red for normal text: red means danger, error, or urgency to most readers. Using it for ordinary paragraphs confuses them.
  • Weak contrast: pale gray on white is the most common readability failure on the web. Check the ratio.
  • Links the same color as text: if readers cannot tell what is clickable, they stop clicking. Give links their own color or an underline.
  • Forgetting hover and visited states: a link that never changes on hover feels dead, and visited links help readers retrace their steps.

Run through that list before you publish and you will catch the problems while they are still free to fix. That is the real lesson behind how to change font color in HTML: the property is one line, but the judgment around it is what makes a page look professional. If you are changing fonts inside WordPress rather than raw HTML, our WordPress font guide covers the five methods that work there.

FAQs

Not in modern HTML. The old font tag that used to do it is obsolete and browsers may drop it at any time. One CSS rule does the same job properly, and it works on every element, not just text.

It is called color. Write color followed by any valid color value, for example color: #1a73e8; inside a rule, a style attribute, or a stylesheet.

Start with color names for practice, then switch to HEX as soon as you want exact shades. HEX is what design tools copy, so it is the format you will meet most in real projects.

Wrap that word in a span element and give the span a class or an inline style. The rest of the paragraph keeps its color, and only the wrapped word changes.

Check four things in order: a typo in the property or value, a more specific rule winning over yours, the browser showing a cached stylesheet, and an inline style on the element overriding your stylesheet.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *