TExcelTAD
Home › HTML › HTML Entities

HTML Entities

Some characters have a special job in HTML. The less-than sign < starts a tag and the ampersand & starts an entity, so if you simply type them into your text the browser may misunderstand you. Character entities are codes that stand for a character, letting you display it safely.

An entity starts with & and ends with ;. It can be written three ways:

Form Example for <
Named &lt;
Decimal number &#60;
Hexadecimal number &#x3C;

Named entities are easier to remember; numeric ones work for any Unicode character.

Reserved characters

These are the characters you most often need to escape:

Character Entity Name When you must escape it
< &lt; less than Always in text, to avoid starting a tag
> &gt; greater than Recommended for symmetry
& &amp; ampersand When followed by text that looks like an entity
" &quot; double quote Inside a double-quoted attribute value
' &apos; apostrophe Inside a single-quoted attribute value
html · try it yourself
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif">
  <p>Typed raw: <b>bold?</b> — the browser made it a real tag.</p>
  <p>Escaped: &lt;b&gt;bold?&lt;/b&gt; — now it is shown as text.</p>
  <p>Fish &amp; Chips, 5 &lt; 7, and a &quot;quoted&quot; word.</p>
  <input value="She said &quot;hello&quot;" size="25">
</body>
</html>

Non-breaking space

HTML collapses multiple spaces into one, and the browser may wrap a line at any space. The non-breaking space &nbsp; is a space that:

  1. never becomes a line break, so the words on either side stay together, and
  2. is not collapsed, so several in a row produce wider gaps.

Use it to keep things like 10&nbsp;km, Mr.&nbsp;Smith or §&nbsp;12 on the same line.

html · try it yourself
<!DOCTYPE html>
<html>
<head>
<style>
  p { width: 150px; border: 1px dashed #aaa; font-family: sans-serif; }
</style>
</head>
<body>
  <p>The race is exactly 42 km long, so pace yourself.</p>
  <p>The race is exactly 42&nbsp;km long, so pace yourself.</p>
  <p>Spaces:    many     ordinary   spaces collapse.</p>
  <p>Spaces:&nbsp;&nbsp;&nbsp;&nbsp;kept&nbsp;&nbsp;&nbsp;wide.</p>
</body>
</html>

In the first box, "42" and "km" may be split across lines; in the second they never are.

Tip: Don't use rows of &nbsp; for layout or indentation. Use CSS margins and padding instead — &nbsp; is for keeping words together.

Other useful named entities

Result Entity Description
© &copy; copyright
® &reg; registered trademark
™ &trade; trademark
€ &euro; euro
£ &pound; pound
¥ &yen; yen
° &deg; degree
× &times; multiplication
÷ &divide; division
– &ndash; en dash (ranges: 9–5)
— &mdash; em dash
… &hellip; ellipsis
« » &laquo; &raquo; angle quotes
→ &rarr; right arrow
html · try it yourself
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; line-height: 1.8">
  <p>&copy; 2026 Sunny Shop&trade; &mdash; all rights reserved.</p>
  <p>Price: 19.99&nbsp;&euro; &nbsp;|&nbsp; Oven: 180&deg;C</p>
  <p>Open Mon&ndash;Fri, 9&ndash;17 &rarr; see you soon&hellip;</p>
  <p>3 &times; 4 = 12 and 12 &divide; 4 = 3</p>
</body>
</html>

Diacritics and combining marks

Accented letters such as é or ñ can be typed directly when the page uses UTF-8 (which it should — see the Charset lesson). Numeric entities and combining marks also work: a combining character modifies the letter before it.

html · try it yourself
<!DOCTYPE html>
<html>
<body style="font-family: sans-serif; font-size: 22px">
  <p>Direct: café, señor, Ångström</p>
  <p>Named: caf&eacute;, se&ntilde;or, &Aring;ngstr&ouml;m</p>
  <p>Combining marks: a&#769; o&#771; e&#776; (a + acute, o + tilde, e + diaeresis)</p>
</body>
</html>

Note: Entity names are case-sensitive: &Aring; is Å while &aring; is å. If an entity name is misspelled, the browser just shows the raw text, such as &copyy;.

Test yourself

Which entity displays a less-than sign <?

  1. &lt;
  2. &lt
  3. &less;
  4. &#lt;

What is special about &nbsp;?

  1. It is invisible and takes no space
  2. It is a space the browser will not break a line at or collapse
  3. It starts a new paragraph
  4. It adds a tab character

How would you write the copyright sign using a named entity?

  1. &copyright;
  2. &c;
  3. &copy;
  4. (c)