Skip to main content
HTML Validation

Stray start tag “caption”.

About This HTML Issue

A <caption> element only belongs inside a <table>, as its first child, so the validator reports any <caption> start tag it finds anywhere else.

The <caption> element is the title of a table. When the HTML parser meets a <caption> tag outside a table, it drops the tag: the DOM gets no caption element, and whatever was inside it becomes plain content of the surrounding element. The parser drops the closing tag as well, so the same spot usually also gets a "Stray end tag caption" error.

A common source is an image caption written as <caption> around an <img>. WordPress's [caption] shortcode turns into this markup when its square brackets get swapped for angle brackets, for example after pasting content from one editor into another. To caption an image, use a <figure> with a <figcaption> inside it.

If the caption belongs to a table, move it inside the <table> as its first child. A <caption> inside the table but after the rows gets a different error, saying caption isn't allowed as a child of table in that context.

Invalid example

<div class="photo">
  <caption>
    <img src="harbor.jpg" alt="Fishing boats moored in a harbor">
    Fishing boats in the harbor at sunrise.
  </caption>
</div>

<caption>Opening hours</caption>
<table>
  <tr>
    <th>Monday</th>
    <td>9:00 to 17:00</td>
  </tr>
</table>

Valid example

<figure class="photo">
  <img src="harbor.jpg" alt="Fishing boats moored in a harbor">
  <figcaption>Fishing boats in the harbor at sunrise.</figcaption>
</figure>

<table>
  <caption>Opening hours</caption>
  <tr>
    <th>Monday</th>
    <td>9:00 to 17:00</td>
  </tr>
</table>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries