|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
The HTML above makes for a nice template that you can use whenever youre starting a table. By filling in the headers and data elements with some genuine information, you can produce a table like the one providing some details from a real estate search shown in Figure 6.1. <TABLE> <TR> <!-- Row 1 --> <TH>ID #</TH> <TH>Address</TH> <TH>Bedrooms/Bathrooms</TH> <TH>Heat/AC</TH> <TH>Selling Price</TH> </TR> <TR> <!-- Row 2 --> <TD>AR-1897-3</TD> <TD>1850 North Quincy Street</TD> <TD>4 BR, 2 BA</TD> <TD>Gas/Central Air</TD> <TD>$248,000</TD> </TR> <TR> <!-- Row 3 --> <TD>AR-9854-22</TD> <TD>4614 22nd Street North</TD> <TD>3 BR, 2.5 BA</TD> <TD>Oil/Central Air</TD> <TD>$237,000</TD> </TR> <TR> <!-- Row 4 --> <TD>AR-5634-7</TD> <TD>1022 Glebe Road</TD> <TD>5 BR, 2.5 BA</TD> <TD>Electric/Central Air</TD> <TD>$358,000</TD> </TR> </TABLE>
AlignmentThe beauty of HTML tables is the precise control you have over the alignment of content in individual cells and over the table itself. You can specify two types of alignment:
Aligning the Entire TableYou can use the ALIGN attribute in the <TABLE> tag to specify how the table should be aligned relative to the browser window. Setting ALIGN to LEFT or RIGHT floats the table in the left or right margin, respectively. Floating tables behave much like floating images in that you can wrap text around them. This is how you produce a page element such as the author byline you see in Figure 6.2.
Using the CENTER value of ALIGN centers the table in the browser window, although not all browsers support this. If you cant center a table this way, you can enclose the HTML that produces the table between the <CENTER> and </CENTER> tags. This should become unnecessary, however, as browsers come into compliance with the HTML 4.0 recommendation.
Alignment Within a RowIf you want the vertical or the horizontal alignment to be the same for every cell in a given row, you can use the VALIGN and ALIGN attributes in the rows <TR> tag. Any alignment specified in a <TR> tag will override all default cell alignments.
Alignment Within a CellHTML 4.0 permits alignment control all the way down to the cell level. You can prescribe vertical or horizontal alignments in both header and data cells by using the VALIGN or ALIGN attributes in <TD> tags. Any alignment specified at the cell level overrides any default alignments and any alignments specified in a <TR> tag. Setting alignments in individual cells represents the finest level of control of table alignment. In theory, you can manually specify vertical and horizontal alignments in every single cell of your tables if you need to. Unfortunately, its easy to get lost among all those VALIGN and ALIGN attributes, especially when it comes to deciding which will take precedence. If you have trouble mastering table alignment, remember the following hierarchy:
Controlling Other Table AttributesIn addition to tweaking alignments, you have a say in other aspects of the tables you create. These include
The next six sections walk you through each of these table features and discuss the HTML tags and attributes you need to know to produce them.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |