HTML Color Flashcards
HTML color
HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA, or HSLA values.
color of text
<h1>Hello World</h1>
<p>Lorem ipsum...</p>
<p>Ut wisi enim...</p>
Border Color
<h1>Hello World</h1>
<h1>Hello World</h1>
<h1>Hello World</h1>
Color Values
colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA values.
The following three <div> elements have their background color set with RGB, HEX, and HSL values:
rgb(255, 99, 71)
#ff6347
hsl(9, 100%, 64%)
Transparency of color
rgb(255, 99, 71, 0.5 for half)
hsl(9, 100%, 64%, 0.9) for 90%
rgb and rgba
An RGB color value represents RED, GREEN, and BLUE light sources.
An RGBA color value is an extension of RGB with an Alpha channel (opacity).
parameter of rgb
Each parameter (red, green, and blue) defines the intensity of the color with a value between 0 and 255.
This means that there are 256 x 256 x 256 = 16777216 possible colors!
rgb(255, 0, 0)
red
rgb(0, 255, 0)
green
rgb(0, 0, 255)
blue
rgb(0, 0, 0)
Black
rgb(255, 255, 255)
White
rgba(red, green, blue, alpha)
alpha means 0 transparency
HEX Color Values
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 other two (green and blue) are set to 00.
Another example, #00ff00 is displayed as green, because green is set to its highest value (ff), and the other two (red and blue) are set to 00.
To display black, set all color parameters to 00, like this: #000000.
To display white, set all color parameters to ff, like this: #ffffff.
HSL
HSL stands for hue, saturation, and lightness.
HSLA color values are an extension of HSL with an Alpha channel (opacity).
HSL
Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240 is blue.
Saturation is a percentage value. 0% means a shade of gray, and 100% is the full color.
Lightness is also a percentage value. 0% is black, and 100% is white.