|
|
HTML table code - Tables part 4How would you design a table that looks similar to one below?
Okay, here goes... <TABLE BORDER="1" CELLPADDING="0" CELLSPACING="0" WIDTH="300" HEIGHT="200"> <TR> <TD ALIGN="CENTER" ROWSPAN="3" WIDTH="100">Column 1</TD> <TD ALIGN="CENTER" WIDTH="200">Row 1</TD> </TR> <TR> <TD ALIGN="CENTER">Row 2</TD> </TR> <TR> <TD ALIGN="CENTER">Row 3</TD> </TR> </TABLE>
As the code shows, The table consists of three rows. The first contains two cells while the other two have only one cell. Now lets look at COLSPAN <TABLE BORDER="1" CELLPADDING="0" CELLSPACING="0" WIDTH="300" HEIGHT="70"> <TR> <TD ALIGN="CENTER" COLSPAN="3"><B>Satisfying hunger? </B></TD> </TR> <TR> <TD ALIGN="CENTER" WIDTH="100" BGCOLOR="#DDFFDD"><IMG SRC="apple1.gif" WIDTH="32" HEIGHT="32" ALT="..."></TD> <TD ALIGN="CENTER" WIDTH="100" BGCOLOR="#AAFFAA"><IMG SRC="apple2.gif" WIDTH="32" HEIGHT="32" ALT="..."></TD> <TD ALIGN="CENTER" WIDTH="100" BGCOLOR="#00C000"><IMG SRC="apple3.gif" WIDTH="32" HEIGHT="32" ALT="..."></TD> </TR> </TABLE>
The code shows that the table consists of two rows. The first row contains only one cell which carries COLSPAN="3" attribute. Thus, this cell will be stretched over three columns. The next row has three cells that make three columns. As an added bonus, cells of the second row have a different background color. Actually the second row HAS to consist of three cells for the first row to span them correctly. Browsers generally will not display tables properly if there is difference between the number of columns specified in COLSPAN and the actual number of columns made via <TD> tag. Now play with the code:
Page contents: HTML table code, developing tables in HTML, web page tables, creating tables in html web pages
Page URL: http://www.webdevelopersnotes.com/tutorials/adhtml/ html_table_code_tables_part_4.php3
|
|
||||||||||