Which HTML element is used to add a caption to a table?

Prepare for the Web Design EOPA Test. Study with interactive quizzes and multiple-choice questions, complete with hints and detailed explanations. Get ready for your web design certification!

Multiple Choice

Which HTML element is used to add a caption to a table?

Explanation:
A caption is added to a table using the caption element. This element is placed as the first child inside the table and contains the text that describes or labels the table. Using caption makes the purpose of the table clear to everyone, especially assistive technologies like screen readers, which announce the caption to users before they read the data. The other elements have different roles: thead defines header rows, tfoot defines footer rows, and colgroup groups and styles columns, but none of them provide a caption. Example: <table><caption>Sales by Quarter</caption><thead>...</thead><tbody>...</tbody></table>. Most browsers show the caption above the table, and you can style it with CSS if you want a different appearance.

A caption is added to a table using the caption element. This element is placed as the first child inside the table and contains the text that describes or labels the table. Using caption makes the purpose of the table clear to everyone, especially assistive technologies like screen readers, which announce the caption to users before they read the data. The other elements have different roles: thead defines header rows, tfoot defines footer rows, and colgroup groups and styles columns, but none of them provide a caption.

Example:

......
Sales by Quarter
. Most browsers show the caption above the table, and you can style it with CSS if you want a different appearance.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy