CHAPTER 13 · HTML
Characters, UTF-8 and entities: display the words and symbols you intend
Your page may contain several writing systems, a price, a copyright symbol or literal HTML tags. This chapter explains how saved characters and character references work together. It also separates HTML escaping from encoding a web address.
Download example files (ZIP)What you will learn
Save and identify UTF-8 consistently. Use named, decimal and hexadecimal character references. Display angle brackets, ampersands and quotation marks safely in examples. Choose a non-breaking space for a real text need. Understand why entities are not encryption or a page-layout system.
Encoding belongs to the saved file
<meta charset="UTF-8">Some characters have a job in HTML syntax
< character can begin markup. An ampersand can begin a character reference. When you want readers to see those characters as text, use a suitable reference instead of accidentally asking the browser to interpret markup.
<p>Write <code><p></code> to start a paragraph.</p>
<p>Research & practice belong together.</p>< represents a less-than sign. The browser displays the character; it does not display that source spelling unless you escape its ampersand too.
Three ways to represent a character
< | ||
< | ||
< |
A useful starting reference table
< | < | |
> | > | |
& | & | |
" | " | |
' | ' | |
© | © | |
|   |
<p title="Read the "Lists" chapter">Start with the reading task.</p>Complete example: display an HTML instruction
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Character Reference Practice</title>
</head>
<body>
<h1>Read the characters carefully</h1>
<p>Example tag: <code><p>Try one page.</p></code></p>
<p>Research & practice.</p>
<p>The spellings <, < and < display the same character.</p>
<p>To show the spelling itself, write <code>&lt;</code>.</p>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.
< because its ampersand was escaped. The reference is decoded once for the document's text; it does not repeatedly turn that resulting text into new markup.
Non-breaking spaces belong between words that should stay together
<p>The walk is 2 km.</p>Symbols, emojis and multilingual text
Complete example: a bilingual practice note
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multilingual Practice Note</title>
</head>
<body>
<h1>Welcome to the study walk</h1>
<p>Welcome: <span lang="hi">नमस्ते</span>.</p>
<p>Route length: 2 km.</p>
<p>Notebook budget: ₹50.</p>
<p>Practice complete ✓</p>
<p>© 2026 Fictional Practice Club.</p>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.
- 1Save the file as UTF-8
- 2Declare UTF-8 near the start
- 3Escape reserved HTML characters
- 4Check the displayed words and symbols
HTML character references and URL percent encoding are different systems.
HTML escaping is different from URL encoding
%20 may represent a space in a URL; writing %20 in an ordinary paragraph does not ask HTML to display a space.
Problem and solution: the sample tag vanishes
<strong> instead creates a real strong element or displays an unexpected result.
Common mistakes and useful tips
Declaring UTF-8 while saving a different encoding. Omitting semicolons or changing case in named references casually. Expecting code to stop nested tags being parsed automatically. Encoding every ordinary character unnecessarily. Using repeated non-breaking spaces to arrange a page. Confusing character references with URL encoding or encryption. Assuming every emoji has the same appearance or meaning everywhere.
Practice questions
Write a character reference for an ampersand. Which character do <and<represent?How do you display the spelling <itself?When might a non-breaking space be useful? Does writing %20in a normal paragraph create a space?Create a small page with an escaped tag example, a direct Unicode symbol and a clearly labelled phrase in a second language.
Check your practice answers
&or&.The less-than sign, <. Escape the ampersand: &lt;.Between a number and its unit where they should stay together, such as 2 and km. It is not a page-layout tool. No. That is URL-encoding notation, not an HTML character reference. Save and declare UTF-8, escape the sample markup and use a suitable lang value for the second-language phrase. Check the actual displayed characters.
Interview questions
Why are character references useful?
Does UTF-8 remove every need for escaping?
What does a non-breaking space change?
Are character references encryption?
Quick revision
Save and declare UTF-8 consistently. Distinguish the document's markup from sample markup displayed as text. Named, decimal and hexadecimal references can identify characters. Use non-breaking spaces sparingly for a real reading need. Keep HTML escaping, URL encoding and security responsibilities separate.