Lists and tables are used to organize and present information in a structured format. HTML provides different types of lists and table elements for displaying data clearly.
<ol>)An ordered list displays items in a numbered sequence.
Use it when the order of items is important.
<ol>
<li>Learn HTML</li>
<li>Learn CSS</li>
<li>Learn JavaScript</li>
</ol>
1. Learn HTML
2. Learn CSS
3. Learn JavaScript
| Tag | Purpose |
|---|---|
ol |
Ordered List |
li |
List Item |
<ol type="A">
<li>HTML</li>
<li>CSS</li>
</ol>
A. HTML
B. CSS
<ol type="a">
<li>HTML</li>
<li>CSS</li>
</ol>
a. HTML
b. CSS
<ol type="I">
<li>HTML</li>
<li>CSS</li>
</ol>
I. HTML
II. CSS
<ol start="5">
<li>HTML</li>
<li>CSS</li>
</ol>
5. HTML
6. CSS
<ul>)An unordered list displays items using bullets.
Use it when the order of items does not matter.
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
• HTML
• CSS
• JavaScript
| Tag | Purpose |
|---|---|
ul |
Unordered List |
li |
List Item |
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Mango</li>
</ul>
• Apple
• Banana
• Mango
<dl>)Definition lists are used to display terms and their descriptions.
| Tag | Purpose |
|---|---|
dl |
Definition List |
dt |
Definition Term |
dd |
Definition Description |
<dl>
<dt>HTML</dt>
<dd>
HyperText Markup Language
</dd>
<dt>CSS</dt>
<dd>
Cascading Style Sheets
</dd>
</dl>
HTML
HyperText Markup Language
CSS
Cascading Style Sheets
A nested list is a list inside another list.
Nested lists are used to create subcategories and hierarchical structures.
<ul>
<li>
Frontend
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</li>
<li>Backend</li>
</ul>
• Frontend
• HTML
• CSS
• JavaScript
• Backend
<ol>
<li>
Setup Environment
<ol>
<li>Install VS Code</li>
<li>Install Browser</li>
</ol>
</li>
<li>Learn HTML</li>
</ol>
1. Setup Environment
1. Install VS Code
2. Install Browser
2. Learn HTML
Lists can be nested multiple levels deep.
<ul>
<li>
Frontend
<ul>
<li>
HTML
<ul>
<li>Tags</li>
<li>Forms</li>
</ul>
</li>
</ul>
</li>
</ul>
<table>)Tables display data in rows and columns.
<table>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>Samir</td>
<td>21</td>
</tr>
</table>
+--------+-----+
| Name | Age |
+--------+-----+
| Samir | 21 |
+--------+-----+
| Tag | Purpose |
|---|---|
table |
Creates a table |
tr |
Table Row |
th |
Table Header |
td |
Table Data Cell |
<table>
<tr>
<th>Course</th>
<th>Duration</th>
</tr>
<tr>
<td>HTML</td>
<td>2 Weeks</td>
</tr>
<tr>
<td>CSS</td>
<td>3 Weeks</td>
</tr>
</table>
HTML provides semantic table sections that improve readability and organization.
<table>
<thead>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
<table>
<thead>
<tr>
<th>Product</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>Laptop</td>
<td>$500</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td>$500</td>
</tr>
</tfoot>
</table>
The rowspan attribute merges cells vertically across multiple rows.
<td rowspan="2">
Frontend
</td>
Frontend | HTML
| CSS
The colspan attribute merges cells horizontally across multiple columns.
<td colspan="2">
Frontend
</td>
+----------------+
| Frontend |
+----------------+
<table border="1">
<tr>
<th>Name</th>
<th>Course</th>
<th>Duration</th>
</tr>
<tr>
<td>Samir</td>
<td>Frontend</td>
<td>3 Months</td>
</tr>
<tr>
<td>Aayush</td>
<td>Backend</td>
<td>4 Months</td>
</tr>
</table>
Name | Age | Address
Price | Quantity | Total
Student | Marks | Grade
| Element | Purpose |
|---|---|
ol |
Ordered List |
ul |
Unordered List |
li |
List Item |
dl |
Definition List |
dt |
Definition Term |
dd |
Definition Description |
table |
Table Container |
tr |
Table Row |
th |
Table Header |
td |
Table Data |
thead |
Table Header Section |
tbody |
Table Body Section |
tfoot |
Table Footer Section |
rowspan |
Merge Rows |
colspan |
Merge Columns |
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
<ol>
<li>Learn HTML</li>
<li>Learn CSS</li>
</ol>
<table>
<tr>
<th>Name</th>
<th>Course</th>
</tr>
<tr>
<td>Samir</td>
<td>Frontend</td>
</tr>
</table>
Lists organize related items.