- Introduction
- HTML Document
- Basic Structure
- Comments
- Elements
- Document Structure Elements
- Metadata Elements
- Sections and Layout Elements
- Headings
- Text Content Elements
- Inline Text Semantic Elements
- Media Elements
- Form Elements
- Table Elements
- Interactive Elements
- Scripting / Template Elements
- Edit Elements
- Semantic, Void and Nested Elements
- Block-level and Inline Elements
- Semantic vs. Non-Semantic Elements
- Attributes
- Favicon
- Colors
- File Paths
- URL (Uniform Resource Locator)
- Responsive Web Design
Table Elements
Learn about HTML Table Elements used to structure and display tabular data effectively, improving readability and accessibility for users and search engines.
HTML Table Elements are used to organize data into rows and columns, making information easier to read and understand.
These elements are essential for displaying structured content like schedules, reports, and comparisons.
Common elements:
table
The <table>
HTML element is used to create a table.
The <table>
element consists of one or more <tr>
(table row), <th>
(table header cell), and <td>
(table data cell) elements.
The <table>
element may also include <caption>
, <colgroup>
, <thead>
, <tfoot>
, and <tbody>
elements.
The <caption>
element defines the title of the table, and the <colgroup>
element specifies a group of one or more columns within a table.
<thead>
, <tfoot>
, and <tbody>
elements are used to define the header, footer, and body of a table, respectively.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<caption>
Items
</caption>
<colgroup>
<col span="3" style="background-color: yellow" />
</colgroup>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <table>
HTML element includes both opening (<table>
) and closing (</table>
) tags.
caption
The <caption>
HTML element defines the caption or title of a table. It includes both opening (<caption>
) and closing (</caption>
) tags.
thead
The <thead>
HTML element is used to define a header for a HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <thead>
HTML element includes both opening (<thead>
) and closing (</thead>
) tags.
tbody
The <tbody>
HTML element is used to define the body of an HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <tbody>
HTML element includes both opening (<tbody>
) and closing (</tbody>
) tags.
tfoot
The <tfoot>
HTML element is used to define a footer for a HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <tfoot>
HTML element includes both opening (<tfoot>
) and closing (</tfoot>
) tags.
tr
The <tr>
HTML element is used to define a table row in an HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <tr>
HTML element includes both opening (<tr>
) and closing (</tr>
) tags.
td
The <td>
HTML element is used to define a table data cell in an HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <td>
HTML element includes both opening (<td>
) and closing (</td>
) tags.
th
The <th>
HTML element is used to define a table header cell in an HTML table.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTML Elements</title>
</head>
<body>
<table>
<thead>
<tr>
<th>S.N</th>
<th>Item</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Apple</td>
<td>2</td>
</tr>
<tr>
<td>2</td>
<td>Mango</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>Orange</td>
<td>1</td>
</tr>
</tbody>
<tfoot>
<tr>
<td></td>
<td>Total</td>
<td>5</td>
</tr>
</tfoot>
</table>
</body>
</html>
The <th>
HTML element includes both opening (<th>
) and closing (</th>
) tags.
colgroup
The <colgroup>
HTML element specifies a group of one or more columns within a table.
It includes both opening (<colgroup>
) and closing (</colgroup>
) tags.