Skip to main content
HTML Validation

Bogus comment.

About This HTML Issue

The HTML parser has specific rules for how it handles sequences that begin with <. When it encounters <! followed by something other than -- (which starts a comment) or DOCTYPE (case-insensitive), the parser doesn’t know how to interpret it. According to the WHATWG HTML Living Standard, such sequences are treated as “bogus comments” — the parser will try to recover by consuming content until it finds a > character, treating everything in between as a comment node. While browsers handle this gracefully through error recovery, the underlying markup is invalid and may not behave as intended.

Several common patterns trigger this error:

  • Malformed comment delimiters: Adding a space between <! and --, using only one hyphen (<!- comment ->), or forgetting the closing -- before >.
  • Stray <! sequences: Accidentally typing <! in your markup without a valid keyword following it, such as <!something>.
  • XML processing instructions: Using <?xml version="1.0"?> or similar <?...?> syntax in an HTML document. Processing instructions are valid in XML/XHTML but are treated as bogus comments in HTML.
  • Mistyped doctype: Writing something like <!DOCKTYPE html> instead of <!DOCTYPE html>.
  • Template or server-side artifacts: Server-side code or templating engines sometimes output fragments like <!--> or <![]> that the HTML parser cannot interpret.

This matters for several reasons. First, since the parser consumes everything up to the next > as a bogus comment, actual content or markup could be swallowed and hidden from the rendered page. Second, different parsers may recover from these errors in slightly different ways, leading to inconsistent rendering. Third, invalid markup can interfere with assistive technologies that rely on a well-formed DOM.

To fix the issue, locate the flagged line in your HTML source and ensure that:

  1. All comments begin with exactly <!-- (no spaces or missing hyphens) and end with exactly -->.
  2. Your <!DOCTYPE html> declaration is correctly spelled.
  3. You haven’t included XML processing instructions (<?...?>) in an HTML document.
  4. No stray <! or <? characters appear in your markup.

Examples

Malformed comment delimiter

<!-- ❌ Space between <! and -- -->

<! -- This is not a valid comment -->

<!-- ❌ Single hyphen instead of double -->

<!- This is not valid either ->

<!-- ✅ Correct comment syntax -->

<!-- This is a valid comment -->

XML processing instruction in HTML

<!-- ❌ Processing instructions are not valid in HTML -->

<?xml version="1.0" encoding="UTF-8"?>
<p>Hello</p>

<!-- ✅ Remove the processing instruction; it's not needed in HTML -->

<p>Hello</p>

Mistyped DOCTYPE

<!-- ❌ Misspelled DOCTYPE triggers bogus comment -->

<!DOCKTYPE html>

<!-- ✅ Correct spelling -->

<!DOCTYPE html>

Stray <! sequence

<!-- ❌ Invalid use of <! -->

<!if condition>
  <p>Conditional content</p>
<!endif>

<!-- ✅ Use standard HTML comments for conditional notes -->

<!-- condition: start -->

<p>Conditional content</p>
<!-- condition: end -->

Empty or broken comment

<!-- ❌ Incomplete comment syntax -->

<!>
<p>Content</p>

<!-- ❌ Another broken variant -->

<!--->
<p>Content</p>

<!-- ✅ Either remove it or write a proper comment -->

<!-- placeholder -->

<p>Content</p>

Conditional comments (legacy IE syntax)

Conditional comments like <!--[if IE]> were a proprietary feature of Internet Explorer. While they don’t typically trigger a bogus comment error (since they start with <!--), related patterns like <![if IE]> (without the --) will. Since IE conditional comments are no longer supported by any modern browser, the best fix is to remove them entirely.

<!-- ❌ Non-comment conditional syntax -->

<![if IE]>
  <link rel="stylesheet" href="ie.css">
<![endif]>

<!-- ✅ Remove legacy conditional comments -->

<link rel="stylesheet" href="styles.css">

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
$7 / 7 days

Pro Trial

Full Pro access. Cancel anytime.

Start Pro Trial →

Join teams across 40+ countries