Add </ to text without HTML thinking it's a tag

Viewed 41

I want to write </Hello (with a bracket at the end), but HTML thinks it is a tag. How do I fix this?

2 Answers

Use &lt; instead of < on html.

<p>&lt;/Hello</p>

You need to use an HTML Escape for both:

  • the less than character (<) which is... &lt;
  • the greater than character {>) which is... &gt;

This will give you:

&lt;/Hello&gt;

which will render in the browser as:

</Hello>


Other useful HTML Escapes include:

  • & => &amp;
  • " => &quot;
  • ' => &#39;
  • < => &lt;
  • > => &gt;
  • [SPACE] => &nbsp;
  • [NEWLINE] => &#13;

Further Reading:

Related