- HTML Color Codes π¨
- Color Picker
- Color Lists
- Color Tools
- What is a HTML color code?
- What are HTML color codes used for?
- What are basic HTML color codes?
- How to Change Text Color in HTML β Font Style Tutorial
- How to Change Text Color Before HTML5
- Welcome to freeCodeCamp! // Using internal/external CSS selector
- How to Change Text Color in HTML
- How to Change Text Color in HTML With Inline CSS
- How to Change Text Color in HTML With Internal or External CSS
- Wrapping Up
HTML Color Codes π¨
The best HTML color codes are waiting for you to find them and they can be found here with all of their names, hex codes, rgb values and other attributes!
Color Picker
Color Lists
Color Tools
Colors from Images
Input an image and find all the colors within!
Color Chart
A reference of colors in a chart grid form.
What is a HTML color code?
A HTML color code is an identifier used to represent a color on the web and within other digital assets. Common color codes are in the forms of: a keyword name, a hexadecimal value, a RGB (red, green, blue) triplet, or a HSL (hue, saturation, lightness) triplet. Different values allow for 16,777,216 potential colors to be chosen.
For example, the color red can be identifier using the following formats:
Because there are so many colors to choose from, tools have been created to make the task of selection much simpler. A color picker allows a user to select a color by clicking on visual range of color to pin-point an exact code. A color chart provides a listing of common colors for quick selection.
To use a selected color code within your web page, you could place the following attribute within a given element to change its background color to red: style=»background-color: #ff0000;»
What are HTML color codes used for?
HTML color codes are used within HTML and CSS to create web design color schemes. They are primarily used by web designers, graphic designers, computer programmers, and digital illustrators. Choosing the correct web colors can be exhausting, but it is a great skill to have, especially for marketing purposes.
To read more about html colors, Wikipedia has a good resource on web colors: https://en.wikipedia.org/wiki/Web_colors.
What are basic HTML color codes?
A few common color codes are:
black, #000000, rgb(0,0,0) white, #FFFFFF, rgb(255,255,255) silver, #C0C0C0, rgb(192,192,192 grey, #808080, rgb(128,128,128) maroon, #800000, rgb(128,0,0) red, #FF0000, rgb(255,0,0) purple, #800080, rgb(128,0,128) fuchsia, #FF00FF, rgb(255,0,255) green, #008000, rgb(0,128,0) lime, #00FF00, rgb(0,255,0) olive, #808000, rgb(128,128,0) yellow, #FFFF00, rgb(255,255,0) navy, #000080, rgb(0,0,128) blue, #0000FF, rgb(0,0,255) teal, #008080, rgb(0,128,128) aqua, #00FFFF, rgb(0,255,255)
How to Change Text Color in HTML β Font Style Tutorial
Joel Olawanle
Text plays a significant role on our web pages. This is because it helps users learn what the web page is all about and what they can do there.
When you add text to your web pages, this text defaults to a black color. But sometimes you will want to change the text color to be more personalized.
For example, suppose you have a darker color as the background of your website. In that case, you’ll want to make the text color a lighter, brighter color to improve your websiteβs readability and accessibility.
In this article, you will learn how to change the color of your text in HTML. We’ll look at various methods, and we’ll discuss which method is best.
How to Change Text Color Before HTML5
Before the introduction of HTML5, you’d use to add text to websites. This tag takes the color attribute, which accepts the color as a name or hex code value:
Welcome to freeCodeCamp. // Or Welcome to freeCodeCamp.
This tag got depreciated when HTML5 was introduced. This makes sense because HTML is a markup language, not a styling language. When dealing with any type of styling, it is best to use CSS, which has the primary function of styling.
This means for you to add color to your web pages, you need to make use of CSS.
In case you are in a rush to see how you can change the color of your text, then here it is:
// Using inline CSSWelcome to freeCodeCamp! // Using internal/external CSS selector
Suppose you are not in a rush. Let’s briefly dive right in.
How to Change Text Color in HTML
You can use the CSS color property to change the text color. This property accepts color values like Hex codes, RGB, HSL, or color names.
For example, if you want to change the text color to sky blue, you can make use of the name skyblue , the hex code #87CEEB , the RGB decimal code rgb(135,206,235) , or the HSL value hsl(197, 71%, 73%) .
There are three ways you can change the color of your text with CSS. These are using inline, internal, or external styling.
How to Change Text Color in HTML With Inline CSS
Inline CSS allows you to apply styles directly to your HTML elements. This means you are putting CSS into an HTML tag directly.
You can use the style attribute, which holds all the styles you wish to apply to this tag.
You will use the CSS color property alongside your preferred color value:
// Color Name Value Welcome to freeCodeCamp!
// Hex Value Welcome to freeCodeCamp!
// RGB Value Welcome to freeCodeCamp!
// HSL Value Welcome to freeCodeCamp!
But inline styling isn’t the greatest option if your apps get bigger and more complex. So let’s look at what you can do instead.
How to Change Text Color in HTML With Internal or External CSS
Another preferred way to change the color of your text is to use either internal or external styling. These two are quite similar since both use a selector.
For internal styling, you do it within your HTML file’s tag. In the tag, you will add the tag and place all your CSS stylings there as seen below:
While for external styling, all you have to do is add the CSS styling to your CSS file using the general syntax:
The selector can either be your HTML tag or maybe a class or an ID . For example:
// HTMLWelcome to freeCodeCamp!
// CSS p
// HTMLWelcome to freeCodeCamp!
// CSS .my-paragraph
// HTMLWelcome to freeCodeCamp!
// CSS #my-paragraph
Note: As you have seen earlier, with inline CSS, you can use the color name, Hex code, RGB value, and HSL value with internal or external styling.
Wrapping Up
In this article, you have learned how to change an HTML element’s font/text color using CSS. You also learned how developers did it before the introduction of HTML5 with the tag and color attributes.
Also, keep in mind that styling your HTML elements with internal or external styling is always preferable to inline styling. This is because it provides more flexibility.
For example, instead of adding similar inline styles to all your
tag elements, you can use a single CSS class for all of them.
Inline styles are not considered best practices because they result in a lot of repetition — you cannot reuse the styles elsewhere. To learn more, you can read my article on Inline Style in HTML. You can also learn how to change text size in this article and background color in this article.
I hope this tutorial gives you the knowledge to change the color of your HTML text to make it look better.
Embark on a journey of learning! Browse 200+ expert articles on web development. Check out my blog for more captivating content from me.