Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
HTML Syntax  ›  Lesson

HTML Entities: Writing Special Characters

HTML Entities 12 minAn HTML entity is a code starting with an ampersand and ending with a semicolon that stands for a character which would otherwise be read as markup or is hard to type.

HTML Entities: Writing Special Characters

You are writing a page about maths and type if a < b. The browser sees < and thinks a tag is starting. Characters that HTML uses for its own syntax need a safe way to appear as plain text, and that way is the entity.

The rule

Ampersand, name, semicolon: a character HTML cannot take literally.

An entity is a short code that the browser replaces with a single character. It always starts with & and ends with ;. The ones you will use most:

You want Write
< &lt; (less than)
> &gt; (greater than)
& &amp; (ampersand)
" inside an attribute value &quot;
a space that never breaks a line &nbsp;
© &copy;
<p>In HTML, a paragraph starts with &lt;p&gt;.</p>
<p>Fish &amp; chips, &copy; 2026 Harbour Cafe</p>

The visitor sees "In HTML, a paragraph starts with <p>." and "Fish & chips, © 2026 Harbour Cafe".

Entities can also use numbers. &#169; and &#xA9; both mean ©, using its Unicode code point in decimal or hexadecimal.

Do you need entities for every accented letter or emoji? No. If your page declares UTF-8 encoding (you will do this with a meta tag soon), you can type é, ₹ or 🌧 directly. Entities are essential only for characters that clash with HTML syntax, mainly < and &, and handy for invisible ones like &nbsp;.

The shortcut

Before typing a symbol, ask: "Could the browser mistake this for markup?" If yes, use an entity.

Writing "Tom & Jerry <3" safelyStep 1 of 4
  1. Scan for syntax characters

    The text holds & and <, both of which HTML treats specially.

The trap is forgetting the semicolon. &copy without ; may work by luck in some cases, but the rule is to always close entities with a semicolon.

Drills

Answer fast — trust the rule.

quick drill

Which entity shows a < character as text?

quick drill

How should "R&D" be written in HTML text?

quick drill

What do all entities have in common?

quick drill

Your page uses UTF-8. Do you need an entity to show ₹?

Remember

  • Entity = & + name or number + ;, replaced by one character.
  • Shortcut: if the browser could mistake a character for markup, escape it (&lt;, &amp;).
  • Trap: forgetting the semicolon, or escaping everything when UTF-8 already handles it.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainShowing code on a page

You are writing a tutorial page and want the visitor to literally see the text <p> on screen, not a new paragraph. Explain what goes wrong if you type it directly and how entities fix it.