<caption> Tag — HTML Technical Interview Questions & Answers

A title for a <table>.

<caption> Tag

  • A title for a <table>.
  • <caption> is the <caption> HTML element. HTML uses this tag so the browser (and screen readers) know what the piece is, not only how it looks.
  • Board: <caption>…</caption> Put it in body. Check it in the browser. Attributes go on the opening tag.
  • Trap: wrong nesting or missing a required attribute. CSS can still style it — don’t pick a tag only because of default italics.
  • Interview: name the tag, one attribute if it has a famous one (href, src, alt, for, type), one mistake.

Technical Interview Tip: <caption>: the <caption> HTML element. Example: <caption>…</caption>

Code Examples for <caption> Tag

<caption> Tag — working example

<table>
  <caption>Team roster</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Role</th>
    </tr>
  </thead>
  <tbody>
    <tr><td>Ada</td><td>Engineer</td></tr>
    <tr><td>Lin</td><td>Designer</td></tr>
  </tbody>
</table>

<caption> Tag — use caption, thead/tbody, and scope on th for structure and screen readers.

How to Explain <caption> Tag to an Interviewer

What is the <caption> tag?

the <caption> HTML element <caption>…</caption>

One common mistake?

wrong nesting or missing a required attribute