<center> Centering Displayed TextThe <center> element is a very popular one that centers its enclosed text in the display area of the Web browser. Like many other styling elements and attributes in HTML 4.0, it was deprecated in favor of stylesheets, so it's supported only in XHTML 1.0 Transitional and XHTML 1.0 Frameset. Here are the attributes of this element:
This element supports the following XHTML events: onclick , ondblclick , onmousedown , onmouseup , onmouseover , onmousemove , onmouseout , onkeypress , onkeydown , and onkeyup . The <center> element does just what its name implies: centers text and elements in the browser's display area. The W3C deprecated <center> in HTML 4, so you won't find it in the XHTML 1.0 Strict or XHTML 1.1 DTDs. Nonetheless, <center> remains a favorite element and will be in use for a long time to come. Here's an example of <center> at work centering multiline text: Listing ch16_13.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 <center> Element </title> </head> <body> <center> <h1> Using the <center> Element </h1> </center> <center> The <center> element is a <br /> useful one for centering <br /> text made up of <br /> multiple lines. </center> </body> </html> You can see the results of this XHTML in Figure 16-11. Figure 16-11. Using the <center> element.
The <center> element is still in widespread use, which is why I'm taking a look at it here. However, it has been deprecated, which means that it will disappear from XHTML one day. So what are you supposed to use instead? Take a look at the next topic, the <div> element. |