HTML and CSS Reference
In-Depth Information
The following color units (
<color>
) define several different ways to
designate solid colors and can be used for properties like text
color
,
background-color
, and
border-color
.
In hexadecimal notation, colors are represented by three sets of hexadec-
imal values (base-16), with the first set representing the red (
r
) value, the
second representing the green (
g
) value, and the next representing the
blue (
b
) value based on how displays add light to create the colors you
see. A value of
#000000
represents no light (black),
#ffffff
represents
the most light (white), and
#ff0000
represents only red light (bright red).
body { background-color:
#999
; } /* middle gray */
#rgb
is a shorthand for
#rrggbb
, which is available to use when the two
r
characters match, the two
g
characters match, and the two
b
characters
match (
#a3b
is equivalent to
#aa33bb
).
You can also define RGB colors using decimal notation (sometimes called
functional notation
) along the same 256-step range (0 to 255) that the
hexadecimal values represented. Each value can also be defined as a
percentage of that 256-step range.
body { background-color:
rgb(153,153,153)
; } /* middle
gray */
body { background-color:
rgb(60%,60%,60%)
; } /* middle
gray */