Adding Captions
Part of the Fundamentals section of Coddy's HTML journey — lesson 49 of 60.
In HTML tables, a caption is a title or explanation for the table. It provides a brief description of the table's content, making it easier for users to understand the purpose of the table. Captions are created using the <caption> tag, which should be placed immediately after the <table> tag.
Here's the basic syntax for adding a caption to a table in HTML:
<table>
<caption>Table Caption</caption>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
</table>Challenge
EasyCreate an HTML document that includes a table with a caption. The table should have the following structure:
- A
<table>tag to define the table. - A
<caption>tag with the text "Product Inventory" to describe the table. - A table row (
<tr>) for the header with two header cells (<th>). The header cells should say "Product Name" and "Quantity". - A table row (
<tr>) with two data cells (<td>). The cells should say "Laptop" and "5". - Another table row (
<tr>) with two data cells (<td>). The cells should say "Mouse" and "10".
Cheat sheet
The <caption> tag provides a title or explanation for an HTML table. It should be placed immediately after the <table> tag.
<table>
<caption>Table Caption</caption>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
</table>Try it yourself
<!DOCTYPE html>
<html>
<body>
<!-- Write code here -->
</body>
</html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
2Text and Formatting
HeadingsParagraphsLine BreaksBold and Italic TextBold and Italic AgainRecap - Formatting8Forms and Inputs Part 1
Form BasicsText InputsInput AttributesPassword FieldLabels for InputsRecap - Basic Form11Event Registration Page
Project OverviewHeader Section9Forms and Inputs Part 2
Radio ButtonsCheckboxesDropdownsButtonsButtons in FormsRecap - Forms #1Recap - Forms #2