Require elements to be closed in correct order

Rule ID:
close-order
Category:
HTML Syntax and concepts
Standards:
  • HTML5

HTML requires elements to be closed in the correct order.

Rule details

Examples of incorrect code for this rule:

<!-- closed in wrong order -->
<p><strong></p></strong>
error: Mismatched close-tag, expected '</strong>' but found '</p>' (close-order) at inline:2:13:
  1 | <!-- closed in wrong order -->
> 2 | <p><strong></p></strong>
    |             ^^


error: Mismatched close-tag, expected '</p>' but found '</strong>' (close-order) at inline:2:17:
  1 | <!-- closed in wrong order -->
> 2 | <p><strong></p></strong>
    |                 ^^^^^^^


2 errors found.

<!-- opened but not closed -->
<div>
error: Missing close-tag, expected '</div>' but document ended before it was found (close-order) at inline:2:6:
  1 | <!-- opened but not closed -->
> 2 | <div>
    |      ^


1 error found.

<!-- closed but not opened -->
</div>
error: Unexpected close-tag, expected opening tag (close-order) at inline:2:2:
  1 | <!-- closed but not opened -->
> 2 | </div>
    |  ^^^^


1 error found.

Examples of correct code for this rule:

<p><strong></strong></p>

<div></div>