Free Guides
Language Tutorials

CSS ( Cascading Style Sheet )
Fonts and Text
Fonts
Finally some real control over fonts, yipee!! There are 5 font properties, and 1 shorthand:
- font-family
- font-style
- font-variant
- font-weight
- font-size
- font (shorthand)
| font-family The font-family property specifies what font will be used, ie. Courier, Helvetica, Arial, etc... or if not available what general family to be used: serif, sans-serif, monospace. The fonts are listed in preferred order. One nice thing about listing numerous fonts, is that a character which may not be available in one font will try to be extracted out of the next one listed. Examples:
BODY { font-family: Times,
TimesRoman, serif }
P { font-family: Helvetica, Verdana, Arial, sans-serif } H1 { font-family: Monaco, Courier, monospace } |
Other generic font families that can be used are cursive and fantasy. The generic font families above are serif, sans-serif and monospace. If your font has more than one word use quotes.
|
font-style Valid values for font-style are normal, italic, and oblique. Very straight forward, oblique is similar to italic. font-variant Valid values for font-variant are normal and small-caps. Small caps displays the lowercase letters as scaled down uppercase letters. font-weight This property specifies what you want the font to weigh, ex. 50 lbs of pure Courier. Well not exactly, the weight of the font is the boldness, or lightness of the font. The valid values that you can assign font-weight are:
normal, bold, bolder, lighter
and 100, 200, 300, 400, 500, 600, 700, 800, 900 Note: normal=400, bold=700
absolute size:
point size: ie. 7pt, 22pt, 14pt, 36pt, 72pt, ... pixel size: ie. 100px, 45px, 90px, 10px, ... relative size: key words: xx-small, x-small, small, medium, large, x-large, xx-large percentage: 24%, 58%, 150%, 10%, 100%, ... ems: .24em, .58em, 1.5em, .1em, 1.0em, ... For font-size, ems are equivalent to percentages. Also you only put in the values for the size you want, do not specify the descriptive words absolute size, point size, etc... Pixel sizing is not recommended by Netscape. The relative sizes are relative to the parent element. For example, if a base font size is set in the BODY, then the the relative sizing is relative to that base font size. font Examples:
H1 { font: bolder 72pt Impact,
"New SchoolBook", sans-serif }
H2 { font: 700 36pt/48pt Monaco, Courier, monospace } H5 { font: lighter 12pt Times, TimesRoman, serif } TextThere are 5 text properties that you can specify: |
- word-spacing
- letter-spacing
- text-decoration
- vertical-align
- text-transform
- text-align
- text-indent
- line-height
|
letter-spacing and word-spacing Exactly how it sounds this specify the spacing between letters and words. The valid values are length values, such as em, px, pt, %,... Examples:
P { word-spacing: 0.75em;
letter-spacing: 10px; }
text-decoration I am not exactly sure the minute differences between all of these, play around with different alignments and see what does what. text-transform I'll probably never use them, because I would just type the text how I want it, and wouldn't need a style sheet to control it, but it may be useful somehow. text-align Examples:
.indent1 { text-indent: 1.0em;
}
.indent2 { text-indent: 30px; }
Example:
P.listi { line-height: 80%; }
|