<font> Specifying a Text FontUsing the <font> element, you can you select text size, color , and face. However, this element was deprecated in HTML 4.0, so it's not available in XHTML 1.1 or XHTML 1.0 Strict. It's supported in XHTML 1.0 Transitional and XHTML 1.0 Frameset. Here are this element's attributes:
This element does not support any XHTML events. The <font> element has always been very popular among HTML authors, but with the new emphasis on handling styles in stylesheets, you can imagine that it was headed for extinction . And it has indeed been deprecated in HTML 4.0, which means you'll find it only in the XHTML 1.0 Transitional and Frameset DTDs. Because it's so popular still, I'll cover it here briefly . You can use the <font> element to set a font face, size, and color for text. Here's an example; in this case, I'm displaying text in a large red Arial font: Listing ch16_09.html<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> Using the <font> Element </title> </head> <body> <font size="6" color="#ff0000" face="Arial"> Putting the <font> element to work. </font> </body> </html> The results of this XHTML appear in Figure 16-7. Figure 16-7. Using the <font> element in Netscape Navigator.
You specify font sizes by using the values 1 through 7 . In practice, font size 1 is about 6 points, font size 2 is about 12 points, and so on, but actual sizes vary by system. Here's an example showing the range of possible sizes: Listing ch16_10.html<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title> Using the <font> Element </title> </head> <body> <center> <h1> Using the <font> Element </h1> <font size="1">This is font size 1.</font> <br /> <font size="2">This is font size 2.</font> <br /> <font size="3">This is font size 3.</font> <br /> <font size="4">This is font size 4.</font> <br /> <font size="5">This is font size 5.</font> <br /> <font size="6">This is font size 6.</font> <br /> <font size="7">This is font size 7.</font> </center> </body> </html> The results of this XHTML appear in Figure 16-8. Note that <font> has been deprecated in HTML 4.0 in favor of stylesheets. So how should you replace the <font> element? See the topic " <span> Formatting Text Inline" at the end of this chapter for a good substitute. Figure 16-8. Displaying various fonts sizes in Netscape Navigator.
Besides the simple text-formatting elements, HTML contains elements to arrange text in the display; XHTML supports those elements as well. |