About This HTML Issue
The HTML specification explicitly forbids numeric character references from expanding to certain control characters, and the carriage return (U+000D) is one of them. Even though you can type or
in your markup, the spec defines this as a parse error. Browsers may handle it inconsistently — some will silently discard it, others may convert it to a different character — so relying on it leads to unpredictable behavior across environments.
The reason carriage return is singled out is rooted in how HTML normalizes line endings. During parsing, all carriage return characters (and carriage return + line feed pairs) are normalized to a single line feed (U+000A). Because the character is never preserved as-is, referencing it serves no practical purpose and is treated as an error. The WHATWG HTML Living Standard lists U+000D among the characters that must not appear as numeric character references.
Control characters in general are problematic in HTML text content. Most of them (U+0001 through U+001F, excluding tab, line feed, and form feed) are disallowed. The carriage return falls into this category because, after normalization, it effectively doesn’t exist in the parsed document.
How to fix it
-
Remove it — In most cases, the
reference is unnecessary. Simply delete it. -
Replace with
— If you need a line break character reference (for example, in atitleattribute or apreelement), use (LINE FEED), which is a permitted space character in HTML. -
Use
<br>— If you need a visible line break in rendered content, use the<br>element instead of a character reference.
Examples
Incorrect: using a carriage return character reference
<p>First line Second line</p>
This triggers the validation error because expands to the carriage return control character.
The same error occurs with hexadecimal notation:
<p>First line
Second line</p>
Correct: using a line feed character reference
<p>First line Second line</p>
The reference expands to LINE FEED (U+000A), which is allowed in HTML. Note that in normal flow, this renders as collapsible whitespace — it won’t produce a visible line break unless you’re inside a pre element or using CSS white-space: pre.
Correct: using <br> for a visible line break
<p>First line<br>Second line</p>
If the goal is a visible line break in the rendered output, the <br> element is the standard and most reliable approach.
Correct: line break in an attribute value
Sometimes appears in attribute values where a newline is intended, such as in title tooltips:
<!-- Incorrect -->
<span title="Line one Line two">Hover me</span>
<!-- Correct -->
<span title="Line one Line two">Hover me</span>
The reference is valid and some browsers will render it as a line break within tooltip text, though this behavior is not guaranteed across all browsers.
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.