Color in css.
A valid color is either :
The list of colour is:
Color Name | numerical RGB |
---|---|
aqua | #00ffff |
black | #000000 |
blue | #0000ff |
fuchsia | #ff00ff |
gray | #808080 |
green | #008000 |
lime | #00ff00 |
maroon | #800000 |
navy | #000080 |
olive | #808000 |
orange | #ffA500 |
purple | #800080 |
red | #ff0000 |
silver | #c0c0c0 |
teal | #008080 |
white (white | #ffffff |
yellow | #ffff00 |
Example(s):
body {color: black; background: white }
h1 { color: maroon }
h2 { color: olive }
The RGB color model is used in numerical color specifications. These examples all specify the same color:
Example(s):
em { color: #f00 } /* #rgb */
em { color: #ff0000 } /* #rrggbb */
em { color: rgb(255,0,0) }
em { color: rgb(100%, 0%, 0%) }
The format of an RGB value in hexadecimal notation is a '#' immediately followed by either three or six hexadecimal characters.
The format of an RGB value in the functional notation is 'rgb(' followed by a comma-separated list of three numerical values (either three integer values or three percentage values) followed by ')'.
A numerical RGB is a valid color if:
Short notation with three digit:
The integer value 255 corresponds to :
Ie white can be specified so:
rgb(255,255,255) = rgb(100%,100%,100%) = #FFF
Whitespace characters are allowed around the numerical values.
Values outside the device gamut should be clipped or mapped into the gamut when the gamut is known: the red, green, and blue values must be changed to fall within the range supported by the device.
For a typical CRT monitor, whose device gamut is the same as sRGB, the four rules below are equivalent:
em { color: rgb(255,0,0) } /* integer range 0 - 255 */
em { color: rgb(300,0,0) } /* clipped to rgb(255,0,0) */
em { color: rgb(255,-10,0) } /* clipped to rgb(255,0,0) */
em { color: rgb(110%, 0%, 0%) } /* clipped to rgb(100%,0%,0%) */
Other devices, such as printers, have different gamuts than sRGB; some colors outside the 0..255 sRGB range will be representable (inside the device gamut), while other colors inside the 0..255 sRGB range will be outside the device gamut and will thus be mapped.
The term “transparent black” refers to the color with red, green, blue, and alpha channels all set to zero.
See http://codepen.io/noahblon/pen/ZbjmbK
:root {
--blue: #075ebb;
--info: #17a2b8;
}
#box {
width:50%;
margin: 0 auto;
text-align: center;
padding: 2rem
}
<div id="box" style="background-color:var(--info)">
A box with the info color variable
</div>
See CSS - How to set an opacity (on any element, background image included)