Text alignment can be controlled in many ways as described in this chapter. Most HTML entities like <p>, <h1>, and <hr /> support the use of an align attribute. Using the align attribute in these tags allows you to control the alignment of that one occurrence.
Although the align attribute is still supported by all major browsers, the preferred method of alignment is using style sheets. To align text elements using styles you use the <div> (division) tag with the text-align property. An added bonus to using the <div> tag is that you can align a block of elements at once.
Using the <div> tag and the text-align property to align text:
|
The <font> tag is used to control the size of the font and the font face. The size attribute uses a scale of 1 to 7, with 3 being the default size in most browsers. This may seem a little unusual to you since most of the software that we use today measures the size of the font in points. Just to help you visualize the size of the font a little better, use the following chart as a guideline in comparing the HTML scale to a point size. This is not an exact equation and may vary from one browser to another
Font size 1 = 8 pts.
Font size 2 = 10 pts.
Font size 3 = 12 pts.
Font size 4 = 14 pts.
Font size 5 = 18 pts.
Font size 6 = 24 pts.
Font size 7 = 36 pts.
You can also specify the size in the <font> tag relative to the default size using the + or - characters.
The <font> tag can also be used to control the FACE of the font. The face attribute names a font that needs to be available on the computer system being used to view the page. This sentence is tagged using the Comic Sans MS Font Face. If your system includes this Font family, then the sentence is displayed using the Comic Sans MS font. If you do not have this font available on your system, the sentence will display using the default font for normal text.
A word of caution here, don't design a page that relies on a certain font face to be used. The possibility that your page will display with the desired font relies completely on the viewer's computer system resources.
You can use CSS to modify all of the features offered by the <font> tag. Using the font-family property you can specify a single font, a list of fonts, or a generic font family.
Using the font-family property to apply a font:
|
You can also use CSS to specify the font size using the font-size property. However, this can be a bit complicated due to there being several units of measurement in CSS. A few of the more common measurements are pt (points) and px (pixels).
View a page containing a table with various font size configurations in multiple browsers and in different monitor resolution settings. You'll see differences in the display of the text.
Using the font-size property to apply a font size:
|