Cover Image for HTML Font Color
71 views

HTML Font Color

To set the font color in HTML, you can use the CSS color property. Here’s an example:

HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Font Color Example</title>
    <style>
      .red-text {
        color: red;
      }
      .blue-text {
        color: blue;
      }
      .green-text {
        color: green;
      }
    </style>
  </head>
  <body>
    <h1 class="red-text">This text is red</h1>
    <p class="blue-text">This text is blue</p>
    <span class="green-text">This text is green</span>
  </body>
</html>

In the above example, the CSS color property is used to set the font color for different elements. Inside the <style> tag, three classes are defined: .red-text, .blue-text, and .green-text, each with a different color value.

The <h1> heading element has the red-text class applied, making its text color red. The <p> paragraph element has the blue-text class applied, making its text color blue. And the <span> inline element has the green-text class applied, making its text color green.

You can customize the color values by specifying different CSS color values such as named colors (e.g., red, blue, green), hexadecimal color codes (e.g., #FF0000 for red), RGB values (e.g., rgb(0, 0, 255) for blue), or other valid CSS color representations.

Feel free to adjust the classes, elements, and color values to suit your needs.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS