Page 54 - DCAP202_Fundamentals of Web Programming
P. 54
Unit 5: Creating Tables
<TR>, and then build the row by creating each cell with the beginning cell tag, <TD>, adding the Notes
data for that cell, and then closing the cell with the ending cell tag, </TD>. When you finish all
of the cells for a row, you would then close the row with the ending row tag, </TR>.
Notes For each new row, you would repeat the process of beginning the row, building
each cell in the row, and closing the row.
Example: The following table is an example of a basic table with three rows and two
columns of data.
Data 1 Data 2
Data 3 Data 4
Data 5 Data 6
The codes that generated this table will look like this:
<TABLE>
<TR>
<TD>Data 1</TD>
<TD>Data 2</TD>
</TR>
<TR>
<TD>Data 3</TD>
<TD>Data 4</TD>
</TR>
<TR>
<TD>Data 5</TD>
<TD>Data 6</TD>
</TR>
</TABLE>
This table contains no border, title, or headings. If you wish to add any of these elements to your
table, you need to include additional HTML codes.
5.2.1 Tables and the Border Attribute
If you do not specify a border attribute the table will be displayed without any borders. Sometimes
this can be useful, but most of the time, you want the borders to show.
To display a table with borders, you will have to use the border attribute:
<table border=”1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>
5.2.2 Headings in a Table
Headings in a table are defined with the <th> tag.
<table border=”1">
LOVELY PROFESSIONAL UNIVERSITY 47