Unclosed and mismatched HTML tags are the most common HTML Checker finding. Browsers silently apply error-recovery rules so pages mostly look right, but parsers — search engines, AI crawlers, accessibility tools, CSS selectors — can interpret the same markup differently. Layout bugs that "appear randomly" usually trace back to unclosed tags somewhere upstream. This guide walks through finding, fixing, and preventing them.
wp-content/themes/your-theme/*.php. Use Theme File Editor or SSH.sections/ or snippets/.app/ or components/ JSX files.<!-- BROKEN --> <div class="card"> <h3>Title</h3> <p>Content</p> <!-- missing </div> --> <!-- FIXED --> <div class="card"> <h3>Title</h3> <p>Content</p> </div>
<!-- BROKEN -->
<section>
<article>
Content
</section>
</article>
<!-- FIXED -->
<section>
<article>
Content
</article>
</section>
<!-- BROKEN (HTML5) --> <div class="row" /> <!-- FIXED --> <div class="row"></div>
Self-closing syntax (<tag />) only works for void elements (img, br, hr, meta, link, input) in HTML5. <div /> is parsed as a regular opening tag — the slash is ignored.
<!-- BROKEN (paragraph closes early) --> <p>Some text <div>more content</div> rest of paragraph.</p> <!-- FIXED --> <p>Some text</p> <div>more content</div> <p>rest of paragraph.</p>
HTML auto-closes p when a block element appears inside. Result: the second </p> becomes a stray closing tag.
wp_kses_post() for capabilities-limited users — extend its allowed-tags list rather than disabling it.
valid_elements defines allowed tags, paste_word_valid_elements filters Word paste. CKEditor: config.allowedContent restricts to a known-clean schema. Reject anything outside the schema.
# GitHub Actions - name: Validate HTML run: npx html-validator-cli --file=dist/index.html --format=textFail builds on validation errors. Broken HTML never reaches production again.
Run the HTML Checker again. Unclosed-tag findings should drop to near-zero. Investigate any remaining errors — usually a single user-generated content piece you missed.
Verify the unclosed-tag count has dropped after your fixes.
Run HTML Checker →