South East Asian Institute of Technology, Inc. National Highway, Crossing Rubber, Tupi, South Cotabato
South East Asian Institute of Technology, Inc. National Highway, Crossing Rubber, Tupi, South Cotabato
___________________________________________________
_____________________________________________________
WEEK 6
COURSE OUTLINE
Content:
Tables
IT 123: Web Development 1
Objectives:
General Objective
⮚ To know how to use the four key elements for creating tables.
⮚ To know how to represent complex data using tables.
⮚ To know how to add captions to tables.
Each chapter in this module contains a major lesson involving the basics of Web page coding and
HTML editing tool. The units are characterized by continuity, and are arranged in such a manner that the
present unit is related to the next unit. For this reason, you are advised to read this module. After each
unit, there are exercises to be given. Submission of task given will be every Monday during your
scheduled class hour.
1 Eve Jackson 94
2 John Doe 80
3 Adam Johnson 67
4 Jill Smith 50
Table Headings
The <th> element is used just like the <td> element but its purpose is to represent the heading for either
a column or a row. (The th stands for table heading.) Even if a cell has no content, you should still use a
<td> or <th> element to represent the presence of an empty cell otherwise the table will not render
correctly. (The first cell in the first row of this example shows an empty cell.)
Output
Spanning Columns
Sometimes you may need the entries in a table to stretch across more than one column.
The colspan attribute can be used on a <th> or <td> element and indicates how many columns that cell
should run across. In the example on the right you can see a timetable with five columns; the first
column contains the heading for that row (the day), the remaining four represent one hour time slots.
Output
Note: I added some CSS styles to this example so that you can see how the cells span more than one
column. You will learn how to do this as we continue tackling about tables.
Note: I added some CSS styles to this example so that you can see how the cells span more than one
column. You will learn how to do this as we continue tackling about tables.
Long tables
There are three elements that help distinguish between the main content of the table and the first and
last rows (which can contain different content). These elements help people who use screen readers and
also allow you to style these sections in a different manner than the rest of the table (as you will see
when you learn about CSS).
<thead>
The headings of the table should sit inside the element.
<tbody>
The body should sit inside the element.
<tfoot>
The footer belongs inside the element.
Example Output
Example
<!DOCTYPE html>
<html>
<head>
<body>
<table border="2" bgcolor="#efefef">
<tr>
<th width="150"></th>
<th>Withdrawn</th>
<th>Credit</th>
<th width="150" bgcolor="#cccccc">Balance</th>
</tr>
<tr>
<th>January</th>
<td>250.00</td>
<td>660.50</td>
<td bgcolor="#cccccc">410.50</td>
</tr>
<tr>
<th>February</th>
<td>135.55</td>
<td>895.20</td>
Output
Note:
This example uses the HTML border and bgcolor attributes. No CSS attributes were utilized in this
example.
When building a new website you should use CSS to control the appearance of the table rather than
these attributes. They are only covered here because you may come across them if you look at the code
of older websites.
Review Questions
1. Why do Web designers prefer to use tables instead of frames?
IT 123: Web Development 1
Test Yourself
1. Write the necessary HTML code for your own study timetable. This should look similar to the
one shown below. (Hint: use the colspan and rowspan attributes)
1. Write an HTML code to form a table to show the below values in a tabular form with heading
aas Roll No., Student Name, Subject Name, and values as
Challenge!
1. In your HTML file “gallery.html” try to insert images inside the table.
2. Add some styles in adding images on the table.
3. Then create a new HTML file and save it as “contents.html”.
In your new html file try to put any offered services/products depends on your website that you have
chosen using the table tags.