HTML and CSS Reference
In-Depth Information
This objective covers how to:
Apply styles to text appearance
Apply styles to text font
Apply styles to text alignment, spacing, and indentation
Apply styles to text hyphenation
Apply styles for a text drop shadow
Apply styles to text appearance
Applying styles such as color, bold, or italic makes certain text stand out on a webpage. Any
of these styling techniques can be applied in combination or individually.
Applying color to text
The color of text can be changed by specifying the color property to the CSS element. CSS3
accepts the color value in any of the following three methods.
Hexadecimal value: Specify the color as a hexadecimal value, for example as #00FF00
to display the text in green. The first two digits (base 16) are the value for Red, the
second two digits are the value for Green, and the last two digits are the value for Blue.
This is commonly referred to as the RGB code.
Color name: Use a word to specify the color value, such as green to display the text in
green.
RGB function: Specify the color value using the RGB function, which takes three
parameters, each representing a color spectrum bit value from 0 to 255. For example,
rgb(0,255,0) specifies green as the text color.
The following code demonstrates each method in use.
<style>
h1{
color:#00FF00;
}
h2 {
color: green;
}
h3{
color: rgb(0,255,0);
}
</style>
The output in Figure 4-1 shows the result of applying these styles to a page.
 
 
Search WWH ::




Custom Search