Monday, September 13, 2010

Setting a default font and font color

As mentioned earlier, the body start tag was historically used to house attributes for dealing
with default text and background colors, link colors, and background images. In CSS,
link styles are dealt with separately (see Chapter 5). We’ll look at how to apply backgrounds
later in this chapter.
At this point, it’s worth noting that, when working with CSS, the body selector is often used
to set a default font family and color for the website. We’ll discuss working with text in
more depth in the next chapter, but for now, check out the following CSS:body {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;
background-color: #ffffff;
}
This is straightforward. The font-family property sets a default font (in this case,
Verdana) and fallback fonts in case the first choice isn’t available on the user’s system. The
list must end with a generic family, such as sans-serif or serif, depending on your other
choices. The fonts are separated by commas in the list, and if you’re using multiple-word
fonts, they must be quoted ("Courier New", not Courier New).
The color property’s value defines the default color of text throughout the site. In the
preceding example, its value is #000000, which is the hexadecimal (hex) value for black
(when defining colors in CSS, it’s most common to use hex values, although you can use
comma-separated RGB values if you wish). It’s also advisable where possible to add a background
color for accessibility; in this case, the background color is #ffffff—hex for
white.

No comments:

Post a Comment