This chapter features a wide range of powerful plug-ins for managing most aspects of using and presenting fonts. These include quick access to font families, embedding any of an additional 19 fonts courtesy of Google, changing text size alignment and styles, and adding colors and drop shadows.
There are also handy classes to transform your text, automatically add icons and other characters such as quotation marks, create professional drop cap effects, and more. Between them, there are over 720 classes for doing almost everything you could want to do with text, without having to write your own CSS rules.
Choosing a font for displaying text is very easy using the classes in this plug-in group, as you only need to enter a short name into the class argument of an object. Plus, each font offers fallback fonts so that systems without the exact font you choose will display the closest match that they have. You can also decide when to enable the fonts since there are six versions of each class.
In Figure 4-1, all the available font classes have been used twice: once to display the associated fonts immediately, and again for mouse hover versions. In the second group of fonts, “Lucida Grande” is currently being hovered over.
These classes use the CSS font-family property to assign the font you choose. Fallback fonts are provided for each to ensure that if a computer doesn’t have a particular font, it can at least display the closest one it does have.
For example, the copper class uses the following rule:
font-family: "Copperplate", "Copperplate Gothic Light", serif;
To use a font class, enter its name in the class argument of an object. For example, to change to the Impact font, you could use HTML such as this:
<span class='impact'>Impact</span>
FIGURE 4-1 A typical collection of fonts on a Windows computer
Or, to change a font only when the mouse hovers over the object, you might use this:
<span class='impact_h'>Impact</span>
Or you can combine classes so that, for example, to change the font of an object to Verdana, and then to Georgia when it is hovered over, you might use this:
<span class='verdana Georgia_h'>Impact</span>
You can also use the other class suffixes to enable a font only when it is actively clicked (classname_a), or when it is a link that is part of the object (classname_l), when it is a clicked link that is part of the object (classname_la), or when it is a hovered link that is part of the object (classname_lh).
Here is the code used to create Figure 4-1:
<span class='arial' >Arial</span>, <span class='arialb' >Arial Bold</span>, <span class='arialn' >Arial Narrow</span>, <span class='avant' >Avant Garde</span> <span class='bookman' >Bookman</span> <span class='century' >Century Gothic</span> <span class='copper' >Copperplate</span> <span class='comic' >Comic Sans MS</span> <span class='courier' >Courier</span> <span class='couriern' >Courier New</span> <span class='garamond' >Garamond</span> <span class='gill' >Gill Sans</span> <span class='georgia' >Georgia</span> <span class='helvetica'>Helvetica</span> <span class='impact' >Impact</span> <span class='lucida' >Lucida Grande</span> <span class='lucidacon'>Lucida Console</span> <span class='palatino' >Palatino</span> <span class='tahoma' >Tahoma</span> <span class='times' >Times</span> <span class='timesnr' >Times New Roman</span> <span class='trebuchet'>Trebuchet</span> <span class='verdana' >Verdana</span><br /><br /> <span class='arial_h' >Arial</span>, <span class='arialb_h' >Arial Bold</span>, <span class='arialn_h' >Arial Narrow</span>, <span class='avant_h' >Avant Garde</span> <span class='bookman_h' >Bookman</span> <span class='century_h' >Century Gothic</span> <span class='copper_h' >Copperplate</span> <span class='comic_h' >Comic Sans MS</span> <span class='courie_hr' >Courier</span> <span class='couriern_h' >Courier New</span> <span class='garamond_h' >Garamond</span> <span class='gill_h' >Gill Sans</span> <span class='georgia_h' >Georgia</span> <span class='helvetica_h'>Helvetica</span> <span class='impact_h' >Impact</span> <span class='lucida_h '>Lucida Grande</span> <span class='lucidacon_h'>Lucida Console</span> <span class='palatino_h' >Palatino</span> <span class='tahoma_h' >Tahoma</span> <span class='times_h' >Times</span> <span class='timesnr_h' >Times New Roman</span> <span class='trebuchet_h'>Trebuchet</span> <span class='verdana_h' >Verdana</span>
.arial, .arial_a:active, .arial_h:hover, .arial_l a, .arial_la a:active, .arial_lh a:hover { font-family:"Arial", sans-serif; } .arialb, .arialb_a:active, .arialb_h:hover, .arialb_l a, .arialb_la a:active, .arialb_lh a:hover { font-family:"Arial Black", sans-serif; } .arialn, .arialn_a:active, .arialn_h:hover, .arialn_l a, .arialn_la a:active, .arialbn_lh a:hover { font-family:"Arial Narrow", sans-serif; } .avant, .avant_a:active, .avant_h:hover, .avant_l a, .avant_la a:active, .avant_lh a:hover { font-family:"Avant Garde", sans-serif; } .bookman, .bookman_a:active, .bookman_h:hover, .bookman_l a, .bookman_la a:active, .bookman_lh a:hover { font-family:"Bookman", "Bookman Old Style", serif; } .century, .century_a:active, .century_h:hover, .century_l a, .century_la a:active, .century_lh a:hover { font-family:"Century Gothic", sans-serif; } .copper, .copper_a:active, .copper_h:hover, .copper_l a, .copper_la a:active, .copper_lh a:hover { font-family:"Copperplate", "Copperplate Gothic Light", serif; } .comic, .comic_a:active, .comic_h:hover, .comic_l a, .comic_la a:active, .comic_lh a:hover { font-family:"Comic Sans MS", cursive; } .courier, .courier_a:active, .courier_h:hover, .courier_l a, .courier_la a:active, .courier_lh a:hover { font-family:"Courier", monospace; } .couriern, .couriern_a:active, .couriern_h:hover, .couriern_l a, .couriern_la a:active, .couriern_lh a:hover { font-family:"Courier New", monospace; } .garamond, .garamond_a:active, .garamond_h:hover, .garamond_l a, .garamond_la a:active, .garamond_lh a:hover { font-family:"Garamond", serif; } .gill, .gill_a:active, .gill_h:hover, .gill_l a, .gill_la a:active, .gill_lh a:hover { font-family:"Gill Sans", "Gill Sans MT", sans-serif; } .georgia, .georgia_a:active, .georgia_h:hover, .georgia_l a, .georgia_la a:active, .georgia_lh a:hover { font-family:"Georgia", serif; } .helvetica, .helvetica_a:active, .helvetica_h:hover, .helvetica_l a, .helvetica_la a:active, .helvetica_lh a:hover { font-family:"Helvetica, sans-serif"; } .impact, .impact_a:active, .impact_h:hover, .impact_l a, .impact_la a:active, .impact_lh a:hover { font-family:"Impact", fantasy; } .lucida, .lucida_a:active, .lucida_h:hover, .lucida_l a, .lucida_la a:active, .lucida_lh a:hover { font-family:"Lucida Grande", "Lucida Sans Unicode", sans-serif; } .lucidac, .lucidac_a:active, .lucidac_h:hover, .lucidac_l a, .lucidac_la a:active, .lucidac_lh a:hover { font-family:"Lucida Console", monospace; } .palatino, .palatino_a:active, .palatino_h:hover, .palatino_l a, .palatino_la a:active, .palatino_lha:hover { font-family:"Palatino", "Palatino Linotype", serif; } .tahoma, .tahoma_a:active, .tahoma_h:hover, .tahoma_l a, .tahoma_la a:active, .tahoma_lh a:hover { font-family:"Tahoma", sans-serif; } .times, .times_a:active, .times_h:hover, .times_l a, .times_la a:active, .times_lh a:hover { font-family:"Times", serif; } .timesnr, .timesnr_a:active, .timesnr_h:hover, .timesnr_l a, .timesnr_la a:active, .timesnr_lh a:hover { font-family:"Times New Roman", serif; } .trebuchet, .trebuchet_a:active, .trebuchet_h:hover, .trebuchet_l a, .trebuchet_la a:active, .trebuchet_lh a:hover { font-family:"Trebuchet", sans-serif; } .verdana, .verdana_a:active, .verdana_h:hover, .verdana_l a, .verdana_la a:active, .verdana_lh a:hover { font-family:"Verdana", sans-serif; }
Choosing font styles with CSS can involve up to three different properties. But when you want to choose font styles such as bold, italic, or underline, these classes are much simpler. Figure 4-2 shows the various styles being applied one at a time until all are employed (Internet Explorer doesn’t support the blink property, so on that browser, any blinking text is shown in bold).
FIGURE 4-2 The various font styles supported by these classes
In the second row, the text is set to change font only when hovered over, as is the case with the word Underline.
These classes use three different CSS rules to create different font styles. They also support the suffixes such as _h to apply the new style only when an object is hovered over, and so on. For example, here are the CSS rules used to restore a font’s styling to normal:
font-style: normal; font-weight: normal; text-decoration: none;
Out of all modern browsers, only Internet Explorer will not display blinking text, so the bold attribute is selected instead. This is achieved using a CSS “hack” that only Internet Explorer can see, like this:
font-weight: bold ;
By adding the