How to change text color in HTML

How to change text color in HTML

In this article we will show you how to change the color of text entered in HTML.

Even if you are not a professional website builder, there are times when you need to edit text in HTML. Here we give hints on how to change the color of text in a document in this common markup language for web pages. Most often, the text on websites is black, this tradition comes from paper books. But, if your design idea requires it, or to highlight any fragments or words, you can transform the text into any color.

Changing the text style in the HTML is possible thanks to Cascading Style Sheets (CSS), the stylesheet language used to describe the presentation of a document in HTML.  There are several ways to change text color with CSS: inline, internal, or external CSS.

How to change text color in HTML with inline CSS

This method is called inline because the CSS is placed directly in each HTML tag. You need to put CSS in your tag. For example, if you want to color text blue, you would use the following hex code:

<p style="color: #0000FF">Follow CCM!</p>

How to change text color in HTML with internal or external CSS

However, it is much more convenient and faster to change the color of the text in HTML with internal or external CSS, since you do it directly in the <head> tag and avoid editing every tag in the text in this way.

 In order to apply internal CSS, in the <head> tag, add the <style> tag and place the desired CSS styles next:

<!DOCTYPE html>
<html>
  <head>
    <style>
      selector {
        color: value;
      }
    </style>
  </head>

  // ...

</html>

For external styling, add the CSS style to your CSS file using the general syntax:

// HTML
<p> Follow CCM! </p>

// CSS
p {
  color: #0000FF;
}

Color hex codes

The following primary color hex codes exist:

Black: #000000

Red: #FF0000

Green: #00FF00

Blue: #0000FF

Yellow: #FFFF00

SkyBlue: #00FFFF

Purple: #FF00FF

Grey: #C0C0C0

White: #FFFFFF

These are just the hex codes of the primary colors, but there are also a huge number of shades of colors, and each shade has its own hex code, as well as a correspondence on the RGB scale used to display colors on the monitor.

More HTML questions? Check out our forum!