HTML and CSS Reference
In-Depth Information
RGBA:
The most recent browsers include support for an extended version of the RGB
notation, which allows the designer to define the opacity or alpha value for the color. The
alpha (or a value) is a decimal from 0 (total transparency) to 1 (fully opaque). If, for exam-
ple, your design calls for a blue heading that is half opaque, the CSS declaration would be
h1 { color: rgba(0, 0, 255, .5) } You can use either the numeric or percentage style for
the red, green, and blue values but the alpha must be in decimal format (or, of course, 0 or 1).
So which technique should you use? It really depends on your own background and familiarity with
graphics programs. If you use a graphics program like Adobe Fireworks, which has a screen-based
orientation, you'll be more familiar with hexadecimal values and can easily copy and paste them as
needed. Folks who work with Adobe Photoshop and similar programs can easily pick up RGB val-
ues. Named values can be useful for very quick color assignments that you know will be faithfully
rendered and easily understood in the code.
Be careful using RGBA notation for your text color. Remember that it is
important to keep the contrast between your background and text color high.
Lowering the alpha value toward 0 would likely make the text too transparent
and decrease the readability of the content.
Try iT
In this Try It you learn how to define the color for text.
Lesson requirements
You will need your previously saved file thoreau.html , a text editor, and a web browser.
step-by-step
1.
Open your text editor.
2.
Open the previously saved thoreau.html .
3.
Place your cursor in the h1, h2 CSS rule, at the end of the font-family declaration, and
press Enter (Return).
4.
Enter the following code:
color: rgb(51, 102, 0);
5.
Place your cursor in the p CSS rule, at the end of the font-size declaration, and press Enter
(Return).
6.
Enter the following code:
color: #333333;
Search WWH ::




Custom Search