Other than color, what can you control with CSS? Many things, but one of the important ones is the font. What is a font? A font is a collection of pictures of letters. Huh? A "letter" is some kind of Platonic ideal, like perfect circles or archetypal chairs. It's also a unit of information. Any particular letter is drawn by some person. Some are simple block letters, others are works of art (like medieval illuminated manuscripts). A font is a collection of these pictures, one for each character in the character set.
There are systematic ways in which fonts can be characterized:
"xx-small," "x-small," "small," "medium", "large," "x-large," "xx-large"
You can also use abstract "relative" sizes named "larger" and "smaller," that are relative to the surrounding font.
The conventional wisdom is that sans-serif fonts look best on the web, while serif fonts look better in print (because of the much greater resolution of print). You can read more about Choosing a Font Family. For an in-depth description of Fonts see the Chapter on Typefaces (the formal name of "fonts").
The following example lets you compare fonts along different dimensions. If you choose "all" from the menu, you'll see the font for each possible value in the result window. If you choose a particular value from the menu (such as "normal," which is the default), you'll only see fonts using that one value. If you choose "all" from every menu, you'll see 12x2x7x2=336 font samples. The samples open in another window, and take a few seconds to generate.
Let's see some examples of playing with font properties. Let's define something for the STRONG tag:
This is
<STRONG style="
font-family: Impact;
font-size: 14pt;
font-style: normal;
font-weight: normal
">
certainly
</STRONG>
very interesting.
Note that each font property is on a different line, only for readability. The semi-colons are the key thing; the browser ignores the line breaks. "Impact" is just the name of a font family, just as you'd see on the font menu in MS Word.
This is certainly very interesting.
Because a font is a work of art, many fonts are fall under the copyright laws, which we will discuss later in the course. There are many fonts that are public domain or free, but you should not automatically assume that a font is free.
You can search the web for free fonts (there are many sites that have them), but there's little incentive in this course. A web page will only show up in the font you choose if the font exists on the browser's computer. Stick to common font families for your pages.
A web search turns up many lists of "browser-safe" fonts: fonts that are probably installed on your user's computer. Those lists don't all agree. Here are some helpful links:
The following are useful pages for learning more about fonts. If you find a good page to add to this, please send it to us.
© Computer Science 110 Staff
This work is licensed under a Creative Commons License
Date Modified:
Thursday, 24-Jan-2008 12:29:31 EST