HTML Tables and Lists
HTML Tables and Lists
DCIS1204
SEMISTER TWO
YEAR ONE
HTML Table
A table is a structured set of data made up of rows and columns (tabular data). A table allows you to
quickly and easily look up values that indicate some kind of connection between different types of
data.
The <table> tag defines an HTML table.
Each table row is defined with a <tr> tag. Each table header is defined with a <th> tag. Each table
data/cell is defined with a <td> tag.
By default, the text in <th> elements are bold and c entered
By default, the text in <td> elements are regular and left-aligned.
Note: The <td> elements are the data containers of the table.
They can contain all sorts of HTML elements; text, images, lists, other tables, etc.
HTML table
<!DOCTYPE html>
<html>
<body>
<table border = "1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
HTML table
Table Heading
Table heading can be defined using <th> tag. This tag will be put to replace <td> tag, which is used to represent actual data cell.
Normally you will put your top row as table heading as shown below, otherwise you can use <th> element in any row. Headings,
which are defined in <th> tag are centered and bold by default.
<body>
<table border = "1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Neno</td>
<td>7000</td>
</tr>
</table>
</body>
HTML Table
Table Caption
The caption tag will serve as a title or explanation for the table and it shows up at the top of the table. This tag is
deprecated in newer version of HTML/XHTML.
<body>
<table border = "1" width = "100%">
<caption>This is the caption</caption>
<tr>
<td>row 1, column 1</td><td>row 1, columnn 2</td>
</tr>
<tr>
<td>row 2, column 1</td><td>row 2, columnn 2</td>
</tr>
</table>
</body>
HTML Table
Nested Tables
You can use one table inside another table. Not only tables you can use almost all the tags inside table data tag
<td>.
Note: In HTML5, the <tfoot> element can be placed either before or after the <tbody> and <tr>
elements, but must appear after any <caption>, <colgroup>, and <thead> elements.
NB: Do not use tables for creating web page layouts. Table layouts are slower at rendering, and very
difficult to maintain. It should be used only to display tabular data.
HTML Lists
HTML Lists are used to specify lists of information. All lists may contain one or more list elements. There are
three different types of HTML lists:
<ul> − An unordered list. This will list items using plain bullets.
<ol> − An ordered list. This will use different schemes of numbers to list your items.
<dl> − A definition list. This arranges your items in the same way as they are arranged in a dictionary.
Unordered HTML List
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items will be marked
with bullets (small black circles) by default:
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
HTML Lists
<dl>
<dt>Aries</dt>
<dd>-One of the 12 horoscope sign.</dd>
<dt>Bingo</dt>
<dd>-One of my evening snacks</dd>
<dt>Leo</dt>
<dd>-It is also an one of the 12 horoscope sign.</dd>
<dt>Oracle</dt>
<dd>-It is a multinational technology corporation.</dd>
</dl>
HTML Lists