Module 9 of 12

📖 What Are HTML Entities?

HTML entities are special codes that represent characters that have special meaning in HTML or characters not available on a standard keyboard.

Why We Need Entities

Some characters are reserved in HTML because they have special functions:

If you type these directly in your content, the browser will try to interpret them as HTML code instead of displaying them.

The Problem

<!-- This will BREAK because the browser thinks <p> is a tag --> <p>To create a paragraph, use <p> tags.</p> <!-- This works correctly using entities --> <p>To create a paragraph, use &lt;p&gt; tags.</p>

🔤 Essential HTML Entities

Reserved Characters (Must Escape)

CharacterEntity NameEntity NumberDescription
<&lt;&#60;Less than / opening tag bracket
>&gt;&#62;Greater than / closing tag bracket
&&amp;&#38;Ampersand
"&quot;&#34;Double quotation mark
'&apos;&#39;Single quotation mark / apostrophe

Common Symbols

CharacterEntity NameEntity NumberDescription
©&copy;&#169;Copyright
®&reg;&#174;Registered trademark
&trade;&#8482;Trademark
&euro;&#8364;Euro sign
£&pound;&#163;Pound sign
¥&yen;&#165;Yen sign
§&sect;&#167;Section sign
°&deg;&#176;Degree

Mathematical Symbols

CharacterEntity NameEntity NumberDescription
×&times;&#215;Multiplication
÷&divide;&#247;Division
±&plusmn;&#177;Plus-minus
&ne;&#8800;Not equal
&le;&#8804;Less than or equal
&ge;&#8805;Greater than or equal
½&frac12;&#189;One half
¼&frac14;&#188;One quarter
¾&frac34;&#190;Three quarters

Spacing and Dashes

CharacterEntity NameEntity NumberDescription
&nbsp;&#160;Non-breaking space
&mdash;&#8212;Em dash (long dash)
&ndash;&#8211;En dash (medium dash)
💡 Non-Breaking Space: &nbsp; creates a space that prevents line breaks. Use it between "100 km" or "Mr. Smith" to keep them on the same line.

😀 Emojis and Unicode

Modern browsers support Unicode characters directly, including emojis. You can use them in three ways:

<!-- Method 1: Direct emoji (works in modern editors) --> <p>Welcome to Ethiopia 🇪🇹</p> <!-- Method 2: Unicode decimal --> <p>Welcome to Ethiopia &#127466;&#127468;</p> <!-- Method 3: Unicode hexadecimal --> <p>Welcome to Ethiopia &#x1F1EA;&#x1F1F9;</p>
⚠️ Important: Always declare <meta charset="UTF-8"> in your document head. Without it, special characters and emojis may display as garbled text (mojibake).

✏️ Exercise 9.1: Create a Copyright Footer

Your Task

Create entities.html demonstrating your knowledge of entities:

  1. A paragraph showing how to write HTML code examples using &lt; and &gt; (show at least 3 different tags as text)
  2. A math expression using &times;, &divide;, &frac12;, and &deg;
  3. A copyright footer with &copy; and the trademark symbol &trade;
  4. A sentence with a non-breaking space between a number and unit (e.g., "100 km")
  5. An em dash used correctly in a sentence
  6. Your country's flag emoji

📝 Module 9 Quiz

Test Your Knowledge
1. Which entity represents the less-than sign?
2. Why must you escape & in HTML?
3. What does &nbsp; create?
4. Which entity is the copyright symbol?
5. What meta tag is required for emojis to display correctly?

🎯 Module Summary

← Previous Module Next: Module 10 →