Headings: h1 Through

Headings: <h1> Through <h6>

You use the <h1> through <h6> elements to create headings in your documents. These are the familiar headings from HTML: <h1> creates the largest text and <h6> produces the smallest. These elements are supported in 1.0 Strict, 1.0 Transitional, 1.0 Frameset, and XHTML 1.1. Here are the possible attributes of these elements and which versions of XHTML support them:

  • align Gives the alignment of text in the heading. The possible values are left (the default), center , right , and justify . (XHTML 1.0 Transitional, XHTML 1.0 Frameset.)

  • class Gives the style class of the element. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • dir Sets the direction of text that doesn't have an inherent direction in which you should read it, called directionally neutral text. You can set this attribute to LTR , for left-to-right text, or RTL , for right-to-left text. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • id Refers to the element; set this attribute to a unique identifier. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • lang Specifies the base language used in the element. Applies only when the document is interpreted as HTML. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • style Set to an inline style to specify how the browser should display the element. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • title Contains the title of the element (which might be displayed in ToolTips). (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • xml:lang Specifies the base language for the element when the document is interpreted as an XML document. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

These elements also support these events in XHTML: onclick , ondblclick , onmousedown , onmouseup , onmouseover , onmousemove , onmouseout , onkeypress , onkeydown , and onkeyup .

Headings act much like headlines in newspapers. They are block elements that present text in bold and often are larger than other text. There are six heading tags: <h1> , <h2> , <h3> , <h4> , <h5> , and <h6> . <h1> creates the largest text, and <h6> creates the smallest. Because headings are block elements, they get their own line in a displayed XHTML document.

Here's an example that shows these headings in action:

Listing ch16_06.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>             The &lt;h1&gt; - &lt;h6&gt; Elements         </title>     </head>     <body>  <center>   <h1>This is an &lt;h1&gt; heading</h1>   <h2>This is an &lt;h2&gt; heading</h2>   <h3>This is an &lt;h3&gt; heading</h3>   <h4>This is an &lt;h4&gt; heading</h4>   <h5>This is an &lt;h5&gt; heading</h5>   <h6>This is an &lt;h6&gt; heading</h6>   </center>  </body> </html> 

You can see this XHTML displayed in Netscape Navigator in Figure 16-4. Headings such as these help break up the text in a page, just as they do in newspapers, and they make the structure of your document stand out.

Figure 16-4. Displaying the six levels of headings in Netscape Navigator.

graphics/16fig04.gif



Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net