Hi @anasustic ,
This behavior you're seeing in AEM 6.5—where void elements like <br> and <meta> are rendered with a trailing slash (<br/>, <meta/>)—is due to the XML-style serialization done by HTL (Sightly) or the underlying Sling engine, which defaults to XHTML output mode in many scenarios.
Why this happens
HTL (HTML Template Language) in AEM doesn't render templates as plain HTML. Instead, it uses XML serialization rules from the underlying parsers (like Xerces or SAX). According to XHTML standards, void elements like <br>, <meta>, <img> are self-closing, hence it outputs them as <br/>, <meta/>, etc.
This is compliant with XHTML, but not strictly HTML5, which is what the W3C validator is flagging.
W3C Validator Warning
The W3C HTML validator warns:
“Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.”
That’s because in HTML5, void elements must not be self-closed (e.g., <br> is correct, but <br/> is discouraged though still technically allowed in most browsers).
Options to fix or suppress the issue1. Switch serialization mode to HTML5 (not XHTML): - By default, AEM doesn't give a toggle for this in HTL, but you can customize how the response is written.
2. Post-process HTML output: - Add a filter or servlet filter that rewrites tags like <br/> to <br> before output.
3. Use a custom HTML serializer (complex): - Override the default Sling HTML serializer, but this is usually overkill.
4. Ignore the warning if there's no functional impact: - Browsers handle <br/> and <br> identically.
- Unless you have strict requirements for W3C compliance (e.g., government websites), this is safe to ignore.
Quick Workaround (e.g., in HTL):
If you absolutely need <br> without a slash, consider using a raw string (not ideal, but works):
${'<br>' @ context='unsafe'}
Use this sparingly, as it bypasses XSS protection.
Regards,
Amit
Amit Vishwakarma - Adobe Commerce Champion 2025 | 17x Adobe certified | 6x Adobe SME