HTML Color Specification

This page will teach how to specify colours in HTML.

HTML (HyperText Markup Language) supports a range of colours that can be specified using several methods, including:

Named colours: there are 140 named colours in HTML, such as "red," "green," and "blue," which you can use as the value of the "colour" attribute.

Hexadecimal colours: you can specify a colour using a 6-digit hexadecimal code preceded by a hash symbol (#), such as "#FF0000" for red or "#00FF00" for green.

RGB values: you can specify a colour using a combination of red, green, and blue (RGB) values, with each value ranging from 0 to 255. For example, "RGB (255, 0, 0)" specifies red.

HSL values: you can specify a colour using hue, saturation, and lightness (HSL) values, which can be more intuitive for some users. For example, "hsl(0, 100%, 50%)" specifies red.

Here's an example of how to use HTML to specify the text colour of a heading:

<h1 style="colour: red;">This is a red heading</h1>

Last updated