HTML Guide
Malformed comment syntax has been found, check out the affected comment.
HTML comments are helpful to leave notes about the code right next to it. To create a comment, it must start with <!--
and end with -->
, as in this example:
<!-- Good comment -->
<!--
Comments can
be multi-line
-->
A common cause for a malformed comment is using too many hyphens (-
) as in this example:
<!-- Wrong comment -->
Related W3C validator issues
Remove the xmlns:o attribute from your HTML elements.
When working with HTML documents intended for the web, often using namespaces like in XML documents may result in validation issues under specific standards like the W3C HTML validator. The xmlns:o attribute is typically associated with XML or XHTML documents and may not align with HTML5’s requirements, causing serialization issues in environments expecting XML 1.0 compliance. These attributes are often seen in documents meant to incorporate Microsoft Office-specific XML schemas—information that HTML5 doesn’t require or recognize.
For HTML5 documents, consider restructuring the content to avoid unnecessary XML namespace attributes. HTML5 has evolved away from strict reliance on XML, focusing instead on a more simplified model.
Example:
Before:
<!DOCTYPE html>
<html xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>Page Title</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
After:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
By removing the xmlns:o attribute, the document aligns with HTML5 standards without the unnecessary constraints of XML namespaces.
XML 1.0 names, typically used for the id attribute of elements, must comply with specific constraints, such as:
- Must start with a letter or underscore _
- Subsequent characters can be letters, digits, hyphens -, underscores _, and periods .
- Cannot contain any spaces or special characters
Here’s an example of an invalid name for an ID:
<svg>
<g id="Group 270">
<!-- Content inside the group element -->
</g>
</svg>
This can be fixed by avoiding whitespace inside the name, like this:
<svg>
<g id="group-270">
<!-- Content inside the group element -->
</g>
</svg>
In this example, the id attribute value Group 270 has been changed to group-270 to follow the rules for XML 1.0 names.
Nested comments are not allowed in HTML. When you place an opening comment tag <!-- within an existing comment, it causes a parsing error.
To fix this issue, you should avoid nesting comments. If you need to include multiple comments in your HTML code, you can separate them or consider alternative ways to convey the information without nested comments.
Here’s an example of a nested comments, which is not allowed in HTML:
<!-- This is a valid comment -->
<!-- This <!-- is not allowed --> nested comment -->
To fix the nested comment issue, you can rewrite the comments like this:
<!-- This is a valid comment -->
<!-- Avoid nesting comments and provide comments separately -->
<!-- Another comment here -->