Void Element With Closing Tag

ID

html.empty_tag

Severity

low

Remediation Complexity

low

Remediation Risk

low

Remediation Effort

low

Resource

Reliability

Language

Html

Tags

reliability

Description

Flags a closing tag that belongs to a void element, such as </br> or </img>.

Rationale

Void elements such as br, img and input never take a closing tag because they have no content. A stray closing tag is invalid markup: some browsers ignore it while others insert an extra line break, so the page renders differently across engines.

<br></br>                      <!-- FLAW — </br> is invalid -->

<br>                           <!-- OK — void element, no closing tag -->

Remediation

Remove the closing tag from void elements; a single <br>, <img …​> or <hr> is complete on its own.