10.07.2017 Views

246996016-HTML5-Step-by-Step

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Specifying a Font Family 105<br />

Note In the preceding example, the Cursive font does not appear as you might expect from its<br />

name; it doesn’t look like cursive handwriting. In most browsers, cursive appears as a rounded<br />

version of sans-serif.<br />

By specifying a generic font type as the final font in the family, you can virtually guarantee<br />

that you’ll at least get your last choice. If the browser can’t use any of your preferences,<br />

it will simply render the text using its default font. Here are some common font<br />

families, grouped <strong>by</strong> their similar appearances:<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

Arial Black, Helvetica Bold<br />

Arial, Helvetica, sans-serif<br />

Verdana, Geneva, Arial, Helvetica, sans-serif<br />

Times New Roman, Times, serif<br />

Courier New, Courier, monospace<br />

Georgia, Times New Roman, Times, serif<br />

Zapf-Chancery, cursive<br />

Western, fantasy<br />

You can also add a font-family attribute to individual tags to ensure that the text stands<br />

out. Here’s how you might set an individual paragraph to the second font family from the<br />

preceding list.<br />

<br />

Notice that there are no quotation marks around any of the font names when applied in<br />

this way. Instead, the quotation marks are placed around the entire style rule.<br />

In this exercise, you will assign a default font to all the tags in a document, and then<br />

you’ll override that font choice on a specific paragraph.<br />

SET UP Use the index.htm and default.css files in the practice folder for this topic.<br />

These files are located in the Documents\Microsoft Press\<strong>HTML5</strong> SBS\07Text\<br />

SelectingFont folder. Open the default.css style sheet file in Notepad and open the<br />

index file in Internet Explorer.<br />

1. In the default.css style sheet, add a style rule that defines a font family of Verdana,<br />

Arial, Helvetica, and sans-serif for the tag and the tag, as shown in the<br />

following:<br />

p, li {font-family: "Verdana", "Arial", "Helvetica", sans-serif}<br />

2. Save the file, and then refresh the Internet Explorer display.<br />

The font of all the text in paragraphs and lists changes.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!