HTML Entities

Reserved Characters and Symbols

Encoding reserved and special characters securely in HTML texts.

Some characters are reserved in HTML. For example, if you use the less than (<) or greater than (>) signs, the browser might mistake them for tags. We use HTML entities to display these characters safely.

Essential HTML Entities

  • &nbsp;: Non-breaking space (adds inline spaces).
  • &lt;: Less than (<).
  • &gt;: Greater than (>).
  • &amp;: Ampersand (&).
  • &copy;: Copyright symbol (©).
  • &reg;: Registered trademark symbol (®).

Formatting Examples

  • Write &lt;div&gt; to render <div> safely on screen.
  • Write Copyright &copy; 2026 to display copyright signs.

Interview questions

Sign in to save

Why can we not just type '<' and '>' directly inside paragraph texts?

Because '<' and '>' are reserved delimiters in HTML that signify the start and end of tags. Writing them raw makes browsers try to parse subsequent text as tags, which corrupts layout rendering and triggers validation errors.

Practice

Write a line of text that displays the text 'p & q < r' on screen securely using entities.

Hint: Use &amp; for '&' and &lt; for '<'.