HTML Colors 2025 – HTML colors play a crucial role in web design. They make websites look attractive, highlight important sections, and improve readability. In this guide, we will explore everything about HTML colors using simple, everyday language. By the end of this post, you will know how to use colors effectively in HTML.

What Are HTML Colors?
HTML colors refer to the colors used in web pages to style text, backgrounds, borders, and more. These colors can be defined using names, hexadecimal codes, RGB values, HSL values, and other methods.
Why Are Colors Important in Web Design?
- Make content readable – A good color contrast makes text easier to read.
- Create emotions – Colors evoke emotions (e.g., red for urgency, blue for calmness).
- Improve aesthetics – Beautiful colors make websites visually appealing.
- Guide users – Colors can highlight important buttons or sections.
Now, let’s explore different ways to use colors in HTML.
Ways to Define Colors in HTML

There are several ways to specify colors in HTML:
- Color Names
- Hexadecimal Codes
- RGB (Red, Green, Blue) Values
- HSL (Hue, Saturation, Lightness) Values
Let’s look at each method in detail.
1. Using Color Names
HTML has 140 predefined color names that you can use directly. Here are some examples:
<p style="color: red;">This text is red.</p>
<p style="color: blue;">This text is blue.</p>
<p style="color: green;">This text is green.</p>
Some common color names include:
- Red
- Blue
- Green
- Yellow
- Pink
- Orange
- Black
- White
Using color names is simple, but it limits your choices to only predefined colors.
2. Using Hexadecimal Codes (Hex Codes)
A hex code is a six-character code that represents a color. It starts with #
followed by three pairs of characters, each representing red, green, and blue (RGB).
Examples:
<p style="color: #ff0000;">This text is red.</p>
<p style="color: #0000ff;">This text is blue.</p>
<p style="color: #008000;">This text is green.</p>
Breaking down #ff0000
:
ff
= Red (maximum intensity)00
= Green (zero intensity)00
= Blue (zero intensity)
This means #ff0000
is pure red.
Common hex codes:
- Black:
#000000
- White:
#ffffff
- Gray:
#808080
- Yellow:
#ffff00
- Purple:
#800080
Hex codes allow precise color control, making them popular in web design.
3. Using RGB (Red, Green, Blue) Values
RGB colors use numbers between 0 and 255 to define the intensity of red, green, and blue.
Examples:
<p style="color: rgb(255, 0, 0);">This text is red.</p>
<p style="color: rgb(0, 0, 255);">This text is blue.</p>
<p style="color: rgb(0, 255, 0);">This text is green.</p>
Breaking down rgb(255, 0, 0)
:
255
= Full red0
= No green0
= No blue
RGB provides flexibility, allowing you to create thousands of colors by adjusting values.
4. Using HSL (Hue, Saturation, Lightness) Values
HSL represents colors using three properties:
- Hue (H) – The type of color (0-360 degrees)
- Saturation (S) – Intensity of color (0% – 100%)
- Lightness (L) – Brightness of color (0% – 100%)
Examples:
<p style="color: hsl(0, 100%, 50%);">This text is red.</p>
<p style="color: hsl(240, 100%, 50%);">This text is blue.</p>
<p style="color: hsl(120, 100%, 50%);">This text is green.</p>
HSL is useful when you want to adjust colors based on their brightness or saturation.
Using Colors in Backgrounds and Borders
You can also use colors in backgrounds and borders.
Background Colors
<div style="background-color: lightblue; padding: 20px;">
This is a light blue background.
</div>
Border Colors
<p style="border: 2px solid red; padding: 10px;">This paragraph has a red border.</p>
Opacity and Transparency
You can control the transparency of colors using rgba
and hsla
.
Example using RGBA (Red, Green, Blue, Alpha):
<p style="color: rgba(255, 0, 0, 0.5);">This text is semi-transparent red.</p>
Here, 0.5
makes the text 50% transparent.
Choosing the Right Colors
Here are some tips for choosing colors:
- Use contrasting colors – Dark text on a light background is easier to read.
- Use brand colors – Keep your website colors consistent with your brand.
- Test on different screens – Colors may look different on various devices.
- Avoid too many colors – Stick to a simple color palette for a professional look.
Color Pickers and Online Tools
There are many online tools to help you pick colors:
HTML Colors 2025
Why My HTML Code Isn’t Colored?
If your HTML code isn’t showing colors, here are a few possible reasons:
- You’re using a plain text editor – Not all text editors support syntax highlighting. Use editors like VS Code, Sublime Text, or Notepad++.
- Your file isn’t saved with
.html
extension – Ensure your file is saved asfilename.html
. - Your editor has syntax highlighting turned off – Check your editor settings.
- You’re looking at the output instead of code – The browser displays rendered HTML, not the code itself.
- Broken or missing tags – Unclosed or incorrectly placed tags can cause formatting issues.
How to Change Background Color of Image in HTML
To change the background color of an image, use CSS with the background-color
property:
<img src="image.jpg" style="background-color: yellow; padding: 10px;">
This will add a yellow background around the image.
How to Change Color of Text in HTML
You can change the color of text using the color
property in inline, internal, or external CSS.
<p style="color: red;">This text is red.</p>
Or, using internal CSS:
<style>
p {
color: blue;
}
</style>
<p>This text is blue.</p>
What is the Correct HTML for Adding a Background Color?
The correct HTML to add a background color is using the background-color
property:
<body style="background-color: lightgrey;">
How to Set a Background Color in HTML
To set a background color for an element:
<div style="background-color: lightblue; padding: 20px;">
This is a blue background.
</div>
How Do You Change the Font Color in HTML?
To change font color, use CSS:
<p style="color: green;">This is green text.</p>
How to Change the Link Color in HTML
Use the color
property in CSS:
<a href="#" style="color: orange;">Click here</a>
To change link color states:
<style>
a { color: blue; }
a:hover { color: red; }
a:visited { color: purple; }
a:active { color: green; }
</style>
How to Change a Font Color in HTML

Font colors are set using color
in CSS:
<p style="color: #ff6600;">This is orange text.</p>
How to Change Color Text in HTML
This is another way of asking how to change text color. You can use:
<p style="color: violet;">This text is violet.</p>
How Do You Change Font Color in HTML?
Another way to phrase changing font color:
<p style="color: brown;">This text is brown.</p>
How Do You Change the Color of Text in HTML?
Use the CSS color
property:
<p style="color: cyan;">This text is cyan.</p>
How to Change the Background Color in HTML
Use background-color
:
<body style="background-color: beige;">
Or for a specific element:
<div style="background-color: lightgreen; padding: 10px;">
Green background
</div>
How to Add Color to HTML Text
You can add color using color
in CSS:
<p style="color: magenta;">This text is magenta.</p>
HTML Colors 2025 – FAQs
1. Why is my HTML color not working?
Make sure you’re using the correct CSS syntax, the correct file format (.html
), and that your CSS is correctly linked.
2. How do I make my text bold and colored?
Yes, by using <span>
tags:
<p style=”color: red; font-weight: bold;”>Bold and red text</p>
3. Can I use multiple colors in one text?
Yes, by using <span>
tags:
<p><span style=”color: red;”>Red</span> <span style=”color: blue;”>Blue</span></p>
4. How do I set a gradient background?
<div style=”background: linear-gradient(to right, red, yellow); padding: 20px;”>
Gradient background
</div>
5. What is the best color contrast for readability?
Black text on a white background or high-contrast colors like dark blue on light yellow improve readability.
HTML Colors 2025 – Summary
In this guide, we covered various ways to change text, background, font, and link colors in HTML. You can use color names, hex codes, RGB, or HSL values. Proper color choices make websites more readable and visually appealing.
Now, go ahead and experiment with HTML colors!