The HTML color attribute defines the colors of various elements on a webpages. There are several ways to specify colors in HTML,such as color names, hexadecimal values, RGB values or HSL values.
HTML provides the set of predefined color names that can be used to specify the color of an element.
<p style="color: green;">This text will be green.</p>
Color is defined by RGB values, which range from 0 to 255. RGB stands of Red, Green and Blue. There colors made with the help of three color of combination of RGB.
<p style="color: rgb(0, 255, 0);">This text will be green.</p>
Colors in HTML are represented by six-digit hexadecimal codes beginning with a pound sign(#). The first two hexadecimal digits represents the red value, the next two digits represent the green value, and the last two digits represent the blue value. Each digits goes from 0 to f (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f).
<p style="color: #00ff00;">This text will be green.</p>
HSL stands for Hue, Saturation, and Lightness. This method defines colors by adjustiing hue, saturation, and lightness. This method allows you to defiine colors more easily as it allows for more flexibility.
<p style="color: hsl(0, 100%, 50%);">This text will be red.</p>
In the above example, the first value (0) represents the hue, which in this case is red. The second value (100%) represents the saturation, and the third value (50%) represents the lightness.