HTML and CSS Reference
In-Depth Information
Applying italic style to text
Through the font object, you can also make specific text italic. This is done by specifying the
font-style for the text. The following code demonstrates applying the italic style to all <p>
elements on the webpage:
p{
font-style:italic;
}
Applying the italic style to a text element produces the output shown in Figure 4-3.
FIGURE 4-3 The italic style applied to a text element.
Apply styles to text font
The font CSS object contains other properties to allow you to control how text is rendered on
your pages. You can change the font typeface and control the size of the text. You can control
the font typeface in a few different ways. The first method is to simply rely on the fonts that
are installed on the system rendering the webpage. This is achieved using the font-family as
shown in the following code:
p{
font-family:Arial,'Times New Roman',Webdings;
}
This CSS code renders the fonts in order from left to right until it finds one that is available
on the client computer. If the font name contains spaces, it must be contained within quotes.
If none of the specified fonts are available, the text falls back to the browser's default font.
In the previous example, the client looks first for the Arial font. If that is not installed, it then
looks for the Times New Roman font, and so on. This is a simple approach, but many people
prefer to use fonts that are not available on the system. There are many custom fonts avail-
able on the Internet for inclusion in your web applications. These fonts are known as WOFF
(Web Open Font Format). To use these fonts in your webpage, you define a font family using
the special keyword @font-face .
EXAM TIP
Be aware that certain font types will work in some browsers but not others. It is important
to declare each font type by using @font-face so that the browser has access to the one it
needs.
 
 
 
Search WWH ::




Custom Search