Lecture 05 HTML Tables and Lists
Lecture 05 HTML Tables and Lists
▪ Structure of Table
▪ Unordered List
▪ Description List
Tables
● Tables refer to structured arrangements of information, typically
● The smallest container inside a table is a table cell, which is created by a <td></td>
element ('td' stands for 'table data’).
● By default tables have no borders in order to add borders use border attribute
○ <table border=“1"></table>
Creating table
● If we want four cells, we need to write four <td></td> tags
Result
● As your tables get a bit more complex in structure, it is useful to give them more
structural definition.
● One clear way to do this is by using <thead>, <tfoot>, and <tbody>, which allow
you to mark up a header, footer, and body section for the table.
● When printing a large table that spans multiple pages, these elements can enable
the table header and footer to be printed at the top and bottom of each page.
● Makes it easier to apply CSS styles differently for each part of the table
Adding structure with <thead>, <tfoot>, and <tbody>
● The <thead> element needs to wrap the part of the table that is the
header.
● The <tfoot> element needs to wrap the part of the table that is the footer
— this might be a final row with items in the previous rows summed.
● The <tbody> element needs to wrap the other parts of the table content
that aren't in the table header or footer. It will appear below the table
header.
Merging Columns & Rows
● Attributes colspan and rowspan are used in <td> tags for spanning the cells
○ Milk
○ Eggs
○ Bread
Unordered List
● Every unordered list starts off with a <ul></ul> element — this wraps
● In order to define each list item, we should wrap each list item with
<li></li>
Unordered List Example
Ordered List
● Ordered lists are lists in which the order of the items does matter —
1. Go work
2. Meet supervisor
3. Eat lunch
have some sub-bullets sitting below a top level bullet. Let's take the
● To create a description list in HTML, you use the <dl> element and wrap
each term within <dt> tags and each description within <dd> tags.