Intermediate HTMLLesson 1: Cascading Style SheetsFormatting Text
There are all kinds of ways you can format text using a stylesheet. You've already seen how you can change the color, using the color property and the size, using the size property like this:
.redbig {
color: red;
font-size: 150%;
}
* * Notice font-size is specified here as a percentage. You can give an absolute size in ems or pixels, but the W3C official guidelines on accessibility frown on it. Makes it hard on people who have a sight disability, since it overrides the text sizing option in their browser. * * Let's add some other kinds of formatting. Font Style and Variant
You only get three choices of Font styles:
.italicspec {
font-style: italic;
}
The two choices for variant are
.capitalletters {
font-variant: small-caps;
}
Pretty easy. Let's move on. Font Family Go to pages 158-9 in your text. Notice how different the same text looks with different formatting. As the book explains, you can set fonts using the font-family in several ways:
.fancyfont {
font-family: Arial;
}
.fancyfont {
font-family: sans-serif;
}
.fancyfont {
font-family: "Enview", "Arial", "Helvetica", sans-serif;
}
That's probably getting more complicated than you need for most purposes. If you need to know how to do it, check out page 159 in your textbook. Font Weight Bolding is pretty important. I use it for a lot for things, like HREF's, for example. It's also not hard to do in a stylesheet. Here's the syntax:
.niceandfat {
font-weight: bold;
}
The other way to specify a font weight is with a multiple of 100, where 100 is very light, 400 is regular plain old normal, 700 is bold and 900 is you-don't-wanna-know.
.nicelooking {
font-weight: bold;
font-variant: small-caps;
font-style: normal;
font-family: sans-serif;
font-size: 90%;
}
|