<hr> Creating Horizontal RulesAnother handy element to arrange text is the <hr> horizontal rule element. This element just causes the browser to draw a horizontal line to separate or group elements vertically. It's supported in XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, and XHTML 1.1. Here are the attributes of this elementnote that it includes a few attributes that have been deprecated:
Here are the XHTML events supported by this element: onclick , ondblclick , onmousedown , onmouseup , onmouseover , onmousemove , onmouseout , onkeypress , onkeydown , and onkeyup . It's easy to break up your text with horizontal rules using the <hr> element. This can be very useful in longer documents, and it organizes your document visually into sections. This element is empty and just instructs the browser to insert a horizontal rule. As with many style attributes in HTML 4.0, the <hr> element's align , width , noshade , and size attributes are all deprecated. However, they're still in the XHTML 1.0 Transitional or Frameset DTDs. Here's an example that displays a few horizontal rules of varying width and alignment: Listing ch16_12.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 <hr> Element </title> </head> <body> <center> <h1> Using the <hr> Element </h1> </center> This is <hr />: <hr /> <br /> This is <hr align="left" width="60%" />: <hr align="left" width="60%" /> <br /> This is <hr align="center" width="60%" />: <hr align="center" width="60%" /> <br /> This is <hr align="right" width="60%" />: <hr align="right" width="60%" /> <br /> </body> </html> You can see the results of this XHTML in Figure 16-10, which shows a number of ways to configure horizontal rules. Here's another note: When you set the align attribute, you must also set the width attribute. Figure 16-10. Displaying horizontal rules in Netscape Navigator.
|