About This HTML Issue
When the parser sees </, it expects the start of an end tag — specifically, a sequence like </tagname> where the tag name immediately follows the slash with no spaces, invalid characters, or other unexpected content before the closing >. Anything else is considered “garbage” because it doesn’t conform to the HTML syntax rules for end tags.
This error matters for several reasons. First, browsers enter error-recovery mode when they encounter malformed markup, and different browsers may recover differently, leading to inconsistent rendering. Second, assistive technologies like screen readers rely on a well-formed DOM tree, so malformed tags can disrupt accessibility. Third, what seems like a minor typo can cascade into larger parsing problems — the parser may misinterpret the document structure, causing elements to nest incorrectly or content to disappear.
Here are the most common causes of this error:
-
A space between the slash and the tag name:
</ div>instead of</div>. -
Trying to close a void element:
</br>,</img>, or</input>. Void elements must not have end tags in HTML. -
Accidental or malformed sequences:
</--,</>, or</3appearing in content. -
Displaying markup as text without escaping: Writing
</div>in a paragraph when you meant to show it literally, instead of using</div>. -
Typos or leftover characters:
</p>extraor</p.>where stray characters follow the tag name.
To fix this error, inspect the line indicated by the validator and determine what you intended. If it should be a closing tag, correct the syntax. If it should be visible text, escape the < as <. If it’s an attempt to close a void element, simply remove the end tag entirely.
Examples
Space inside the end tag
A space between </ and the tag name triggers the error:
<!-- ❌ Triggers: Garbage after "</" -->
<p>Hello world.</ p>
<!-- ✅ Fixed: no space after the slash -->
<p>Hello world.</p>
Trying to close a void element
Void elements like br, hr, img, and input must not have end tags:
<!-- ❌ Triggers: Garbage after "</" -->
<p>Line one.</br>Line two.</p>
<!-- ✅ Fixed: use <br> without a closing tag -->
<p>Line one.<br>Line two.</p>
Unescaped markup in text content
If you want to display HTML code as readable text, escape the angle brackets:
<!-- ❌ Triggers: Garbage after "</" -->
<p>To close a paragraph, use </p> at the end.</p>
<!-- ✅ Fixed: escape the angle brackets -->
<p>To close a paragraph, use <code></p></code> at the end.</p>
Accidental or malformed sequences
Stray characters after </ that don’t form a valid tag name:
<!-- ❌ Triggers: Garbage after "</" -->
<p>I </3 cats</p>
<!-- ✅ Fixed: escape the less-than sign -->
<p>I </3 cats</p>
Full document example
<!-- ❌ Triggers the error -->
<!doctype html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<p>This has a bad closing tag.</ p>
<p>Show code: </div> in text.</p>
</body>
</html>
<!-- ✅ Fixed version -->
<!doctype html>
<html lang="en">
<head>
<title>Example</title>
</head>
<body>
<p>This has a correct closing tag.</p>
<p>Show code: <code></div></code> in text.</p>
</body>
</html>
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.