td Creating Table Data

<td> Creating Table Data

The <td> element is where you place the data that you want in a cell in a table. You use this element inside the <tr> element. It's supported in XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, and XHTML 1.1. Here are this element's attributes:

  • abbr Gives an abbreviated name for a cell. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1, 4.)

  • align Sets the horizontal alignment of content in the table cell. You can set this to left , center , right , justify , or char . (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • axis Contains a name for a cell (usually used only with table heading cells ). Allows the table to be mapped to a tree hierarchy. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • bgcolor Deprecated in HTML 4.0. Sets the background color of table cells. (XHTML 1.0 Transitional, XHTML 1.0 Frameset.)

  • char Specifies a character to align text on. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • charoff Sets the alignment offset to the first character to align on (which you set with char ). (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

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

  • colspan Specifies how many columns this cell should span. (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.)

  • headers Specifies a list of header cells that supply header information. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • height Deprecated in HTML 4.0. Sets the height of the cell in pixels. (XHTML 1.0 Transitional, XHTML 1.0 Frameset.)

  • 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.)

  • nowrap Deprecated in HTML 4.0. Indicates that content should not be wrapped by the browser by adding line breaks. (XHTML 1.0 Transitional, XHTML 1.0 Frameset.)

  • rowspan Specifies how many rows of the table this cell should span. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • scope Specifies a set of data cells for which the header cell provides header information. You can set this to row , col , rowgroup , or colgroup . (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • style Inline style indicating how to render the element. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • title Contains the title of the element. (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • valign Sets the vertical alignment of the data in this cell. You can set this to top , middle , bottom , or baseline . (XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1.)

  • width Deprecated in HTML 4.0. Gives the width of the header. (XHTML 1.0 Transitional, XHTML 1.0 Frameset.)

  • 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.)

Here are the events this element supports: onclick , ondblclick , onfocus , onblur , onmousedown , onmouseup , onmouseover , onmousemove , onmouseout , onkeypress , onkeydown , and onkeyup .

You use <td> elements to hold the data in a table's cells. The browser knows how many columns to create in the table depending on how many <td> or <th> elements you put into a row. For example, here's how I add data to the rows of a table using <td> elements:

Listing ch17_06.html
 <!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>             Working With XHTML Tables         </title>     </head>     <body>        <center>            <h1>                Working With XHTML Tables            </h1>             <table>                 <tr>                    <th>TIC</th>                    <th>TAC</th>                    <th>TOE</th>                 </tr>  <tr>   <td>O</td>   <td>X</td>   <td>O</td>   </tr>   <tr>   <td>X</td>   <td>O</td>   <td>X</td>   </tr>   <tr>   <td>O</td>   <td>X</td>   <td>O</td>   </tr>  </table>         </center>     </body> </html> 

You can see the results in Figure 17-4. That's all it takes to create simple tables in XHTML. The process is just like HTMLyou enclose everything in a <table> element, use <tr> to create the rows of a table, and enter the data in each cell using <td> (or <th> for header text).

Figure 17-4. A table written in XHTML.

graphics/17fig04.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