Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

Character Formatting Using CSS 127

7


You can also set the typeface for text using the font-family property. In addition, you
can set the specific font for text, but I’m not going to discuss that until later in the les-
son. In the meantime, let’s look at how you can set the font to a member of a particular
font family. The specific font will be taken from the user’s preferences. The property to
modify is font-family. The possible values are serif, sans-serif, cursive, fantasy,
and monospace. So, if you want to specify that a monospace font should be used with
CSS rather than the now obsolete tag, use the following code:


This is monospaced text.


Now let’s look at one capability not available using regular HTML tags. Using the
font-variant property, you can have your text rendered so that lowercase letters are
replaced with small capital letters. The two values available are normal and small-caps.
Here’s an example:


This Text Uses Small Caps.


The web page in Figure 7.2 contains some text that uses the font-variant property as
well as all the other properties described in this section.


Output ▼


FIGURE 7.2
Text styled using
CSS.

Free download pdf