Professional Documents
Culture Documents
TLE-ICT
COMPUTER PROGRAMMING
QUARTER 2 – MODULE 5
Inserting Tables
1
COMPUTER PROGRAMMING
QUARTER 2 MODULE 5
Inserting Tables
Objectives
• Understand what a table is and how to create and modify it
• Identify the different attributes of tables, rows and data
• Learn to merge cells and nest tables
• Know how to add images to a table
• Build a table with invisible border
What is a Table?
Tables allow you to organize and arrange data into columns and rows. Tables allow you to divide your
page into section where you can place header, footers and navigation links. Almost all Web sites are laid out using
tables.
Before starting to create any kind of table, whether to control the page layout or presentation of data in
tabular format, you should make a plan to help you build your table faster and more accurately.
A table is made up of rows and columns. You can place different elements in each cell like text or image.
Creating a Table
Tables arrange and organize content into columns and rows. Basically, they can be made via the
container tags <table></table>. Each row within the table is defined by the container tags <tr></tr>. Moreover, each
cell or data within a row is defined by the container tags <td></td>.
Remember that the cells <td></td> are placed inside rows <tr></tr> and rows are placed inside the table
<table></table>
Modifying Table
There are various ways to change the appearance of your table. You can change the thickness and color of
the border, set a certain distance between the contents of the cells and the border around it, set its background color
or image, etc. These various ways can be done through the table’s attributes.
2
Attributes for <table></table>
Attribute Definition Values
Name
align Indicates the horizontal alignment of the table. left,right,center
Ex: <table align=”center”><table>
background Indicates the horizontal alignment of the table. Filename (path could be included)
Ex: <table background=”red.Flower.jpg”></table> of the image file
bgcolor Indicates the horizontal alignment of the table. Assigned name or hexadecimal
Ex: <table bgcolor=”red”></table> value of the color
border Indicates the thickness of the border in pixels. Number of pixels
Ex: <tableborder=”2”></table>
bordercolor Indicates the color of the border. Assigned name or hexadecimal
Ex:<table bordercolor=”red”></table> value of the color
cellpadding Indicates the distance (in pixels) between the contents of Number of pixels
the cells and the border around it.
Ex:<table cellpadding=”2”></table>
cellspacing Indicated the distance between the cells in pixels. Number of pixels
Ex: <table cellspacing=”2”></table>
width Indicates the width of the table in pixels or percent of the Number of pixels or number
width displayed by the Web browser. expressed as percent
Ex:<table width=”800”></table>
Specifically, rows’ <tr></tr> appearance can be changed as well and can be done through their attributes. By
default, the contents of table rows are aligned vertically.
3
Modifying Table Data
The appearance of <td></td> data on each cell can be changed through their attributes. The
nowrap attribute needs no value. It just needs to be present in the tag in order for it to provide its effect.
Bear in mind that the alignment set on a cell overrides the alignment set on the row.
4
Merging Cells Horizontally
Cells in the same row can be merged using the colspan attribute of <td></td> and <th></th>.
5
Nesting Tables
Just like lists, tables can be nested. Web page developers use this technique to enhance even more the
layout and structure.
6
Adding an Image to a Table
You can add image to a cell by using the tag pair <td><img src=” …”>.
7
ACTIVITIES
1. This allows you to organize and arrange data into columns and rows.
2. What tag should be used to create a table in HTML?
3. The attribute that is used to indicate the distance (in pixels) between the contents of the cells and
the border around it.
4. The attribute that is used to indicate the horizontal alignment of the table.
5. The attribute that is used to indicate the background color of the row.
6. The attribute that is used to indicate the distance between the cells in pixels.
7. The attribute that is used to indicate the thickness of the border in pixels.
8. The attribute that is used to indicate the width of the table in pixels or percent of the width displayed
by the Web browser.
9. The attribute that is used to inhibit word wrapping in the cell.
10. The attribute that is used to merge multiple cells.
II. Enumerate me
Direction: Enumerate all the attributes you used in test III. Your answers here should match the codes
used in Test III.
OUTPUT CODE
8
9
Figure 1
Week 1
6 AM – 7
AM
8 -9 AM
9-10 AM
10-11 AM
11 AM –
12 NN
12 NN –
1 PM
1 -2 PM
2- 3 PM
3 – 4 PM
5 – 6 PM
7 -11 PM
11 PM –
12 AM
WEEK 2
WEEK 3
10