Skip to main content
HTML Validation

Unclosed element “X”.

About This HTML Issue

Every non-void HTML element needs a matching end tag. When one is missing, the browser's error recovery kicks in and decides where the element ends. The resulting DOM tree can differ from what the source code suggests, breaking layout, CSS selectors, and JavaScript that depends on a specific structure. Screen readers and other assistive technologies also rely on correct nesting to convey document structure to users.

This error commonly appears when tags are closed out of order. HTML requires last-in-first-out nesting: the most recently opened element must be closed first. Another frequent cause is copy-paste editing that removes a closing tag while leaving the opener behind. Note that void elements (<br>, <img>, <input>, <meta>, <hr>, <link>) never have closing tags. Writing <br></br> is invalid in HTML and can trigger a related error.

Examples

Missing closing tag

<!-- Bad: the outer <div> is never closed -->
<div class="card">
  <h2>Title</h2>
  <p>Some text</p>
  <div class="footer">
    <p>Footer text</p>
  </div>

Fixed

<div class="card">
  <h2>Title</h2>
  <p>Some text</p>
  <div class="footer">
    <p>Footer text</p>
  </div>
</div>

Out-of-order closing tags

<!-- Bad: <em> is opened inside <strong> but closed after </strong> -->
<p><strong><em>Important</strong></em> notice</p>

Fixed

<p><strong><em>Important</em></strong> notice</p>

Consistent indentation makes nesting mismatches easier to spot by eye. Editor features like bracket matching, and tools like Prettier or HTMLHint, can catch these problems before you run the validator. If you use a templating language, make sure conditional blocks do not skip required end tags.

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
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries