tables lab5. drawing a table tables are the web designer’s best friend and worst enemy. to draw a...
TRANSCRIPT
Tables
lab5
Drawing a table
Tables are the web designer’s best friend and worst enemy.
To draw a table we will use: <TABLE> tag <TR> for raw <TD> tags for column.
Cont. example <TABLE border=1> <TR> <TD>First Row</TD> <TD>First Row</TD> <TD>First Row</TD> </TR> <TR> <TD>First Row</TD> <TD>First Row</TD> <TD>First Row</TD> </TR> </TABLE>
>table<
>table<
>tr <
>tr<
>td< />tr<>td< >td<
>td<>td< >td< />tr<
Table attributes border Specifying table sizes (width-height) You can specify width for
a table both in percents of page width and in pixels.Example :<TABLE WIDTH=50% BORDER=1> <TR> <TD>Cell Row1 Col1</TD> <TD>Cell Row1 Col2</TD> </TR> <TR> <TD>Cell Row2 Col1</TD> <TD>Cell Row2 Col2</TD> </TR>
Cont. determine table width in pixels.
<TABLE WIDTH=250 BORDER=1> <TR> <TD>Cell Row1 Col1</TD> <TD>Cell Row1 Col2</TD> </TR> <TR> <TD>Cell Row2 Col1</TD> <TD>Cell Row2 Col2</TD></TR></table>
Cont.
You can specify table height too. In this way you can determine height and width of table. Width
and height of table will be divided between cells in rows and columns so if table width is 100 and
there are 2 columns then width of each cell will be 50.
if you put a lot of text in a cell of a table it will be
expanded to fit the text in it.
Text alignment in table cells
<TD ALIGN=CENTER> or <TD ALIGN=RIGHT> or <TD ALIGN=LEFT> // by default
vertical alignment Use VALIGN option to <TD> tag (TOP, BOTTOM and MIDDLE.
MIDDLE is default.
Example :<TABLE WIDTH=50% HEIGHT=100 BORDER=3> <TR> <TD ALIGN=LEFT VALIGN=TOP> sami </TD> <TD ALIGN=RIGHT VALIGN=TOP> engineer </TD> </TR> <TR> <TD ALIGN=LEFT VALIGN=BOTTOM> ali </TD> <TD ALIGN=RIGHT VALIGN=BOTTOM> doctor </TD> </TR></TABLE>
Merge cells colspan and rowspan attributes
in the <td>...</td> tags. Eg. Column merging<table border=1> <tr> <td colspan="2">b</td> </tr> <td> </td> <td> </td> </table>
b
Cont.
Row merging
<table border=1>
<tr>
<td rowspan="2">jhgjhghg</td>
<td>hgfhbvv</td>
</tr>
<tr>
<td>jjj</td>
</tr>
</table>
Images in table cells inserting <IMG> tag between <TD></TD>
tags of a certain cell.
<BODY><TABLE BORDER=4> <TR> <TD><IMG SRC="image53.gif"></TD> </TR></TABLE>