On this page11 sections
  1. Learning Objectives
  2. 1. Why Entities Exist
  3. 2. Entities You'll Use Most
  4. 3. The Non-Breaking Space
  5. 4. Symbols
  6. 5. Diacritical Marks
  7. 6. Emojis
  8. Common Beginner Mistakes
  9. Practice Questions
  10. Practice Answers
  11. Key Takeaways

Lecture 027: Entities, Symbols & Emojis

Category5: Code, Characters & Standards
Lecture027 of 048
Estimated video length12 min
TargetHTML5 · any modern browser
LevelBeginner

Some characters have a special meaning in HTML, so you can't just type them. Others, such as © or →, aren't on your keyboard. Entities let you write any character, including maths symbols, currency signs and emojis, using a short code.


Learning Objectives

  • Write reserved characters such as <, > and & with entities
  • Use named and numeric entities for symbols
  • Keep words together with a non-breaking space
  • Add emojis to a page

1. Why Entities Exist

The browser reads < as the start of a tag. To show a < on the page, write &lt;.

Example

html
<p>In HTML, a paragraph starts with &lt;p&gt; and ends with &lt;/p&gt;.</p>
<p>Fish &amp; chips costs &lt; Rs 1,000.</p>

An entity starts with & and ends with ;.


2. Entities You'll Use Most

ShowsNameNumber
<&lt;&#60;
>&gt;&#62;
&&amp;&#38;
"&quot;&#34;
'&apos;&#39;
©&copy;&#169;
®&reg;&#174;
™&trade;&#8482;
(non-breaking space)&nbsp;&#160;

Names are easier to remember; numbers work for every character.


3. The Non-Breaking Space

A normal space lets the browser start a new line there. &nbsp; doesn't, so it keeps things together, such as a number and its unit.

Example: drag the preview corner narrower:

html
<p style="width: 180px; border: 1px dashed #aaa;">The flight takes 10&nbsp;hours and costs Rs&nbsp;95,000.</p>

Don't use lots of &nbsp; for spacing. That's a job for CSS.


4. Symbols

Example

html
<p>Maths: 5 &times; 4 &divide; 2 &ne; 11 &nbsp; | &nbsp; &sum; &radic; &infin; &le; &ge;</p>
<p>Arrows: &larr; &uarr; &rarr; &darr; &harr;</p>
<p>Currency: &euro; &pound; &yen; &#8360; (rupee sign)</p>
<p>Greek: &alpha; &beta; &pi; &Omega;</p>
<p>Card suits: &spades; &clubs; &hearts; &diams;</p>

5. Diacritical Marks

Accents can be added to a letter with a combining character after it:

html
<p>a&#768; a&#769; a&#770; a&#771;</p>

In practice, since your page uses UTF-8 (Lecture 028), you can simply type é, ü or ñ.


6. Emojis

Emojis are ordinary characters, so you can paste them straight in, or use their numbers.

Example

html
<meta charset="UTF-8">
<p style="font-size: 40px;">😀 &#128512; &#x1F600;</p>
<p>Ready? &#127881; Let's go &#128640;</p>
  • &#128512; is the decimal number; &#x1F600; is the same in hexadecimal.
  • Emojis look different on Android, iPhone and Windows, because each draws its own.
  • Use them as decoration; important meaning should also be in words.

Common Beginner Mistakes

1. Forgetting the semicolon. &copy may work, but &copy; always does.

2. A raw & in URLs inside HTML. Strictly it should be &amp;: href="search?q=tea&amp;page=2". Browsers usually cope, but validators complain.

3. Spacing with &nbsp;&nbsp;&nbsp;. Use CSS margins and padding.

4. Emojis as the only label. A screen reader may say "rocket", which might not be what you mean.


Practice Questions

  1. How do you show <div> as text on a page?
  2. What's the entity for the copyright symbol?
  3. What does &nbsp; do?
  4. Write "5 × 3 = 15" using an entity for the multiplication sign.
  5. Name two ways to add an emoji to a page.
  6. Why do emojis look different on different phones?

Practice Answers

  1. &lt;div&gt;
  2. &copy;
  3. It's a space that never breaks onto a new line.
  4. 5 &times; 3 = 15
  5. Paste the emoji directly, or use its number, such as &#128512;.
  6. Each operating system draws its own emoji pictures.

Key Takeaways

  • Entities start with & and end with ;: &lt;, &gt;, &amp;, &copy;.
  • Numeric entities (&#169;) can write any character.
  • &nbsp; keeps words together on one line.
  • Emojis are characters: paste them, or use &#…;.