HTML Handout 1
HTML Handout 1
CHAPTER 3
HTML
What is a website?
A website is a collection of individual but related web pages that are often stored
together and hosted by a web server. Web pages can include different objects such
as text, sound, video and still images.
What is HTML?
BASIC TAGS
1 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
2 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
Tables
1. Introduction
Tables are data arranged into rows and columns to a web page. Tables may
be used to organize calendars, schedules, statistics, or other types of information. A
table cell may contain any sort of information, including numbers, text elements, and
even images and multimedia objects.
2. Table elements
All of the table’s content goes into cells that are arranged into rows. Cells are the heart of
the table, because that’s where the actual content goes
A table element
Start and end table tags (<table> and </table>) are used to identify the beginning and
end
of the table.
A table rows
The element tr is used to define the table row (tag <tr> and </tr>). The tr element
contain
3 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
number of cells.
A table cells
Cells contain either header information (titles for the columns) or data which may be
any content. The element th (<th> and </th>) is used as table header , it is displayed
differently from the other cells in the table. Table headers are important because they
provide information about the cells they precede. The element td (<td> and </td>) is
used as cell data. The number of columns in a table is determined by the number of
cells in each row. This is one of the things that make HTML tables potentially tricky.
Columns are implied with rows, for example, if a table has four columns then each
row must contain four td or th elements.
Example 1: For create a simple table with three rows and three columns that lists Food
Information
Caption
The caption element is used to give a table a title or brief description that displays
next to
4 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
Example 2
<html>
<table border = "1">
<caption>Student Information </caption>
<tr>
<th> Name </th>
<th> Class </th>
<th> Id </th>
</tr>
<tr>
<td> Student 1 </td>
<td> Second </td>
<td> 753 </td>
</tr>
<tr>
<td> Student 2</td>
<td> Third </td>
<td> 951</td>
</tr>
</table>
</html>
OUTPUT:
5 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
3. Spanning Cells
One fundamental feature of table structure is cell spanning, which is the stretching of
a cell to cover several rows or columns.
• Column spans
Column spans are created with the colspan attribute in the td or th element, stretch a
cell
to the right to span over the subsequent columns as presented in example below
where a
column span is used to make a header apply to two columns.
Example 3
<html>
6 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
Note: Every row should have the same number of cells or equivalent colspan
values. In example 3, the second row has two td elements, and in the first row there
is only one th element but the colspan value is 2, so the implied number of columns
in each row is equal.
Activity 1 :
• Row spans
Row spans are created with the rowspan attribute, work just like column spans, but
they
cause the cell to span downward over several rows. In example 4, the first cell in the
table
<html>
<tr>
</tr>
7 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
<tr>
</tr>
<tr>
</tr>
</table> </html>
OUTPUT:
Activity 2:
Write HTML Code for the following table
html>
<head>
<title>
HTML table bgcolor Attribute
</title>
8 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
</head>
<body>
<tr>
<th>NAME</th>
<th>AGE</th>
<th>BRANCH</th>
</tr>
<tr>
<td>BITTU</td>
<td>22</td>
<td>CSE</td>
</tr>
<tr>
<td>RAM</td>
<td>21</td>
<td>ECE</td>
</tr>
</table>
</body>
</html>
OUTPUT:
9 HTML HANDOUT
THE INDIAN PUBLIC SCHOOL – CAMBRIDGE INTERNATIONAL
10 HTML HANDOUT