A.2. Text PropertiesThe following properties affect how text is formatted on a Web page. Since most of the properties in this category are inherited, you don't necessarily have to apply them to tags specifically intended for text (like the <p> tag). You can apply these properties to the <body> tag, so that other tags inherit and use the same settings. This technique is a quick way to create an overall font, color , and so on for a page or section. A.2.1. color (inherited)Sets the color of text. Since it's inherited, if you set the color of the <body> tag to red, for example, all text inside of the bodyand all other tags inside the <body> tagis red, too.
Note: The preset link colors for the <a> tag override color inheritance. In the above example, any links inside the <body> tag would still be standard hyperlink blue. See Section 9.1 for ways to change preset link colors. A.2.2. font (inherited)This is a shortcut method for cramming the following text properties into a single style declaration: font-style, font-variant, font-weight, font- size , line-height , and font-family . (Read on for the individual descriptions.) You must separate each value by a space and include at least font-size and font-family, and those two properties must be the last two items in the declaration. The others are optional. If you don't set a property, the browser uses its own preset value, potentially overriding inherited properties.
A.2.3. font-family (inherited)Specifies the font the browser should use to display text. Fonts are usually specified as a series of three to four options to accommodate the fact that a particular font may not be installed on a visitor's computer. See Section 6.1.1.
A.2.4. font-size (inherited)Sets the size of text. This property is inherited, which can lead to some weird behaviors when using relative length measurements like percentages and ems.
Note: When the font-size property is inherited from another tag, these keywords multiply the inherited font size by the same factor (1.2 in most browsers). A.2.5. font-style (inherited)Makes text italic. Applied to italic text, it turns it back to plain text. The options italic and oblique are functionally the same.
A.2.6. font-variant (inherited)Makes text appear in small caps, like this: SPECIAL PRESENTATION. The value normal removes small caps from text already formatted that way.
A.2.7. font-weight (inherited)Makes text bold, or removes bolding from text already formatted that way.
A.2.8. letter-spacing (inherited)Adjusts the space between letters to spread out letters (adding spacing between each) or cram letters together (removing space).
A.2.9. line-height (inherited)Adjusts space between lines of text in a paragraph (often called line spacing in word processing programs). The normal line height is 120 percent of the size of the text (Section 6.4).
A.2.10. text-align (inherited)Positions a block of text to the left, right, or center of the page or container element.
A.2.11. text-decorationAdds lines above, under, and/or through text. Underlining is common with links, so it's usually a good idea not to underline text that isn't a link. The color of the underline, overline, or strike-through line is the same as the font color of the tag being styled. The property also supports a blink value that makes text flash off and on obnoxiously.
A.2.12. text-indent (inherited)Sets the indent size of the first line of a block of text. The first line can be indented (as in many printed books) or outdented, so that the first line hangs off and over the left edge of the rest of the text.
A.2.13. text-transform (inherited)Changes the capitalization of text, so text appears in all uppercase letters, all lowercase, or only the first letter of each word capitalized.
A.2.14. vertical-alignSets the baseline of an inline element relative to the baseline of the surrounding contents. With it, you can make a character appear slightly above or below surrounding text. Use this to create superscript characters like , , or . When applied to a table cell , the values top, middle, bottom , and baseline control the vertical placement of content inside the cell (Section 10.2.1).
A.2.15. white-spaceControls how the browser displays space characters in the HTML code. Normally, if you include more than one space between words"Hello Dave"a Web browser displays only one space"Hello Dave." You can preserve any white space exactly as is in the HTML using the pre value, which does the same as the HTML <pre> tag. In addition, Web browsers will split a line of text at a space, if the line won't fit within the window's width. To prevent text from wrapping, use the nowrap value. But the nowrap value makes all of the paragraph's text stay on one line, so don't use it with long paragraphs (unless you like the idea of making your visitors scroll endlessly to the right).
A.2.16. word-spacing (inherited)Works like the letter-spacing property (Section A.1.1), but instead of letters, it adjusts space between words.
|