CSS Colors
Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.
CSS Colors Names
HTML support 140 colors names :-
CSS 1–2.0, HTML 3.2–4, and VGA color names
White | #FFFFFF | 100% | 100% | 100% | 0° | 0% | 100% | 0% | 100% | 15 (white) |
Silver | #C0C0C0 | 75% | 75% | 75% | 0° | 0% | 75% | 0% | 75% | 07 (light gray) |
Gray | #808080 | 50% | 50% | 50% | 0° | 0% | 50% | 0% | 50% | 08 (dark gray) |
Black | #000000 | 0% | 0% | 0% | 0° | 0% | 0% | 0% | 0% | 00 (black) |
Red | #FF0000 | 100% | 0% | 0% | 0° | 100% | 50% | 100% | 100% | 12 (high red) |
Maroon | #800000 | 50% | 0% | 0% | 0° | 100% | 25% | 100% | 50% | 04 (low red) |
Yellow | #FFFF00 | 100% | 100% | 0% | 60° | 100% | 50% | 100% | 100% | 14 (yellow) |
Olive | #808000 | 50% | 50% | 0% | 60° | 100% | 25% | 100% | 50% | 06 (brown) |
Lime | #00FF00 | 0% | 100% | 0% | 120° | 100% | 50% | 100% | 100% | 10 (high green); green |
Green | #008000 | 0% | 50% | 0% | 120° | 100% | 25% | 100% | 50% | 02 (low green) |
Aqua | #00FFFF | 0% | 100% | 100% | 180° | 100% | 50% | 100% | 100% | 11 (high cyan); cyan |
Teal | #008080 | 0% | 50% | 50% | 180° | 100% | 25% | 100% | 50% | 03 (low cyan) |
Blue | #0000FF | 0% | 0% | 100% | 240° | 100% | 50% | 100% | 100% | 09 (high blue) |
Navy | #000080 | 0% | 0% | 50% | 240° | 100% | 25% | 100% | 50% | 01 (low blue) |
Fuchsia | #FF00FF | 100% | 0% | 100% | 300° | 100% | 50% | 100% | 100% | 13 (high magenta); magenta |
Purple | #800080 | 50% | 0% | 50% | 300° | 100% | 25% | 100% | 50% | 05 (low magenta) |
Background-Color
You can set the background-color for HTML elements.
Example
<!DOCTYPE html>
<html>
<head>
<title>Css Colors </title>
</head>
<body>
<h1 style="background-color: red">Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors. Colors may be specified as an RGB triplet or in hexadecimal format (a hex triplet) or according to their common English names in some cases. A color tool or other graphics software is often used to generate color values.
</h1>
<p style="background-color:blue;"> In some uses, hexadecimal color codes are specified with notation using a leading number sign.A color is specified according to the intensity of its red, green and blue components, eachrepresented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and
16,777,216 colors that may be so specified. </p>
</body>
</html>
Result
Text color
You can set the color of text.
You can set the color of text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Css Text color </title>
</head>
<body>
<h1 style="color: green">Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors. Colors may be specified as an RGB triplet or in hexadecimal format (a hex triplet) or according to their common English names in some cases. A color tool or other graphics software is often used to generate color values.
</h1>
<p style="color:blue;"> In some uses, hexadecimal color codes are specified with notation using a leading number sign.A color is specified according to the intensity of its red, green and blue components, eachrepresented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified.
</p>
</body>
</html>
Result
Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors. Colors may be specified as an RGB triplet or in hexadecimal format (a hex triplet) or according to their common English names in some cases. A color tool or other graphics software is often used to generate color values.
In some uses, hexadecimal color codes are specified with notation using a leading number sign.A color is specified according to the intensity of its red, green and blue components, eachrepresented by eight bits. Thus, there are 24 bits used to specify a web color within the sRGB gamut, and 16,777,216 colors that may be so specified.
Border Color
You can set the color of border.
Hello world
Example
<!DOCTYPE html>
<html>
<head>
<title>Css Text color </title>
</head>
<body>
<h1 style="border: 1px solid #f00;">Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors.
</h1>
<p style="border: 1px solid blue;"> In some uses, hexadecimal color codes are specified with notation
using a leading number sign.. </p>
</body>
</html>
Result
Web colors are colors used in displaying web pages on the World Wide Web, and the methods for describing and specifying those colors.
In some uses, hexadecimal color codes are specified with notation using a leading number sign..
Color Values
In HTML, colors can also be specified using
RGB values, HEX values, HSL values, RGBA values, and HSLA values:
- rgb(255, 99, 71)
- #ff6347
- hsl(9, 100%, 64%)
Example
<h1 style="background-color:rgb(255, 99, 71);">...</h1>
<h1 style="background-color:#ff6347;">...</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>
You also must read this article :
Click Here
RGB Value
In HTML, a color can be specified as an RGB
value, using this formula:
rgb(red, green, blue)
Each parameter (red, green, and blue) defines the intensity of the color between 0 and 255.
For example, rgb(255, 0, 0) is displayed as red,
because red is set to its highest value (255) and the others are set to 0.
To display the color black, all color parameters must be set to 0, like this: rgb(0, 0, 0).
To display the color white, all color parameters must be set to 255, like this: rgb(255, 255, 255).
- rgb(255, 99, 71)
- rgb(255, 0, 0)
- rgb(60, 179, 113)
- rgb(255, 165, 0)
- rgb(106, 90, 205)
HEX value
In HTML, a color can be s
pecified using a hexadecimal value in the form:
#rrggbb
Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff (same as decimal 0-255).
For example, #ff0000 is displayed as red, because red is set to its highest value (ff)
and the others are set to
the lowest value (00).
- #ff0000
- #ffa500
- #ee82ee
- #6a5acd
- #787878
- #ffffff
RGBA
RGBA color values are an extension of RGB color values with an alpha channel - which specifies the
An RGBA color value is specified with:
rgba(red, green, blue, alpha)
The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (not transparent at all):
- rgba(255, 99, 71, 0)
- rgba(255, 99, 71, 0.8)
- rgba(255, 99, 71, 0.6)
- rgba(255, 99, 71, 1)