What is 
?

Learn what is ? with practical examples, diagrams, and best practices. Covers html, entities development techniques with visual explanations.

Understanding : The Carriage Return HTML Entity

Hero image for What is 
?

Explore the meaning and usage of the 
 HTML entity, its historical context, and why it's generally discouraged in modern web development.

In the world of web development, you might occasionally encounter cryptic character entities. One such entity is 
. While it might look like a random string of numbers, it represents a specific control character with a rich history: the carriage return. Understanding what 
 signifies and its implications is crucial for debugging layout issues and writing robust HTML.

What is ?

The 
 entity is the numeric character reference for the ASCII character with decimal value 13. This character is known as the Carriage Return (CR). Historically, on typewriters and early computer terminals, a carriage return would move the print head or cursor to the beginning of the current line without advancing to the next line. It's often paired with a Line Feed (LF) character (
 or \n) to create a new line, a combination known as CRLF (\r\n).

flowchart TD
    A[Typewriter Action] --> B{"Carriage Return (CR)"}
    B --> C[Move print head to start of line]
    C --> D{"Line Feed (LF)"}
    D --> E[Advance paper one line]
    E --> F[New Line (CRLF)]

Historical function of Carriage Return and Line Feed

Why You Might See in HTML

While 
 is a valid HTML entity, it's rarely used intentionally in modern web development. Its presence often indicates one of the following scenarios:

  1. Legacy Systems or Data: Content originating from older systems, databases, or text files that explicitly used carriage returns might preserve them as 
 when rendered in HTML.
  2. Incorrect Encoding/Decoding: If text is not properly encoded or decoded, especially when moving between different operating systems (e.g., Windows uses CRLF, Unix/Linux uses LF for newlines), a lone carriage return might appear.
  3. Copy-Pasting Issues: Copying text from certain applications or terminals that include explicit carriage returns can sometimes transfer them into HTML as entities.
  4. Debugging/Inspection: You might see 
 when inspecting the raw HTML source or network responses, especially if the server or client-side script is not sanitizing or processing newline characters as expected.

Impact on Rendering and Best Practices

Modern web browsers generally normalize whitespace in HTML. This means that multiple spaces, tabs, newlines (\n), and carriage returns (\r) within text content are often collapsed into a single space. Therefore, a 
 entity in your HTML will usually not produce a visible line break or any other distinct visual effect.

Best Practices:

  • For Line Breaks: Always use the <br> tag for explicit line breaks within a paragraph or block of text.
  • For Paragraphs: Use <p> tags to define paragraphs, which naturally create block-level spacing and new lines.
  • For Preformatted Text: If you need to preserve all whitespace, including newlines and carriage returns, use the <pre> tag. This tag renders text exactly as it's written, respecting all whitespace characters.
  • Sanitize Input: When dealing with user-generated content or data from external sources, always sanitize and normalize newline characters to prevent unexpected &#13; or &#10; entities from appearing in your rendered HTML.
<!-- Incorrect usage of &#13; for a line break -->
<p>This is the first line.&#13;This should be the second line, but it won't be.</p>

<!-- Correct usage for a line break -->
<p>This is the first line.<br>This is the second line.</p>

<!-- Preserving whitespace with <pre> -->
<pre>
This text
  preserves
    all
      whitespace,
      including
      newlines.
</pre>

Demonstrating incorrect and correct ways to handle line breaks in HTML.