HTML Code for Font color

Understanding Font Color in HTML

In HTML, the font color property is used to change the color of text within an element. This can be done using the 'color' attribute in the opening tag of the element.

Setting Font Color

To set the font color in HTML, you can use the 'color' attribute within the opening tag of the element. The value of the 'color' attribute can be a color name, a hex value, or an RGB value.

Using Color Names

When using color names, you can directly specify the color name such as 'red', 'blue', 'green', etc. HTML supports a wide range of color names that can be used to set the font color.

Using Hexadecimal Values

Hexadecimal color values are also widely used in HTML for setting font colors. These values start with a hash '#' followed by a combination of six letters and numbers which represent the color.

Using RGB Values

RGB (Red, Green, Blue) values can also be used to specify font colors in HTML. This method involves specifying the intensity of red, green, and blue colors in the format 'rgb(x, y, z)' where x, y, and z are values between 0 and 255.

Example Code

<h1 style='color: red'>This is a heading</h1>

Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free