HTML and CSS Reference
In-Depth Information
Figure 4.1
Using a transpar-
ent background
color to make
solid text more
readable against
a background
image.
The
r
,
g
, and
b
values work on the same scale as their
rgb()
unit coun-
terparts discussed earlier in this chapter. The alpha (
a
) value is a decimal
number from 0 to 1, with 0 being completely transparent and 1 being
fully opaque.
section { background-color:
rgba(0,200,0,0.1)
; } /* very
transparent green */
Color units with alpha values of 1 are equivalent to using the solid
color unit. Consider using that solid color unit instead because it may
be supported by more browsers.
Like
rgba()
,
hsla()
is the same color as
hsl()
with an added designation
for alpha transparency. This unit is also a decimal number from 0 to 1.
a { background-color:
rgba(0,0,0,0.9)
; } /* almost solid
black */