freecoding.school100% FREE · NO SIGNUP
Markup CityISSUE #34 of 39

entities · & · < ·  

Tagg the BuilderVSThe Unclosed Tag
Tagg the Builder saysCharacter entities let you display reserved characters like < > & by writing their codes instead of the symbols.

Some characters mean something to HTML. A literal < would start a tag; & starts an entity. To show them as plain text you write entities: &lt; for <, &gt; for >, &amp; for &, &quot; for ".

There's also &nbsp; — a non-breaking space that won't collapse or let text wrap. Entities come in named (&copy;) and numeric (&#169;) forms; the numeric code always works when you can't remember a name.

Power-ups you unlock

The Unclosed Tag attacks — common mistakes

Boss battleMake the page literally display the text <p>hi</p> as characters (not a rendered paragraph) using entities.

Example code

<!doctype html>
<html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace">
  <p>show a tag as text: &amp;lt;p&amp;gt;hi&amp;lt;/p&amp;gt; →  &lt;p&gt;hi&lt;/p&gt;</p>
  <p>ampersand: Salt &amp;amp; Pepper → Salt &amp; Pepper</p>
  <p>copyright: &amp;copy; → &copy;</p>
</body></html>
▶ Open the interactive comic issue
‹ Style Guide · Keeping Markup CleanSymbols · Math · Currency · Arrows ›