Homepage

UnclosedHTMLElement

Last edit: Apr 01, 2026

UnclosedHTMLElement

Severity: warning | Type: LiquidHtml

This check warns you of unbalanced HTML tags in branching code. This situation commonly arises when Liquid conditionals open an HTML element in one branch but not another, leaving the HTML structure invalid in certain code paths.

Unbalanced HTML causes unpredictable rendering behavior across different browsers and can break CSS layout, JavaScript DOM queries, and screen readers.

Examples

✗ Incorrect Code Example (Avoid using this):


{% if show_wrapper %}
  <div class="wrapper">
{% endif %}
  <p>Content</p>
{% if show_wrapper %}
  </div>
{% endif %}

When show_wrapper is false, the <p> is rendered without a wrapper. When show_wrapper is true, the <div> is opened and closed — but this pattern can confuse parsers and is fragile.

✓ Correct Code Example (Use this instead):


{% if show_wrapper %}
  <div class="wrapper">
    <p>Content</p>
  </div>
{% else %}
  <p>Content</p>
{% endif %}

Or using a CSS class instead of conditional wrapping:


<div class="wrapper{% unless show_wrapper %} wrapper--hidden{% endunless %}">
  <p>Content</p>
</div>

Configuration

The default configuration for this check:

UnclosedHTMLElement:
  enabled: true
  severity: warning

Disabling This Check

This check can be disabled if you intentionally use split HTML tags across Liquid branches as part of a deliberate pattern. Use the platformos-check-disable comment to suppress specific instances.

Questions?

We are always happy to help with any questions you may have.

contact us