HTML Entities
Some characters are special in HTML. If you type a raw < in ordinary page text, the browser may think a tag is starting. If you type a raw &, it may think an entity is starting. Character entities are safe codes that display those symbols as visible text instead of confusing the parser.
What is an HTML entity?
An HTML entity is a coded way to write a character in markup. Most named entities start with & and end with ;. The browser replaces the code with the real character when it renders the page. You need entities most often for characters that HTML already uses as markup syntax, and sometimes for symbols that are awkward to type.
Direct answer
Use entities when a character would be unsafe or unclear as raw text. Remember these first: < for <, > for >, & for &, and for a non-breaking space. Always finish a named entity with ;. Use them in paragraphs, and inside HTML-teaching examples, whenever the raw character would break or misread the document.
Common entities at a glance
📊 Common entities
| Entity | Shows | Use |
|---|---|---|
| &lt; | less-than | Safer than a raw opening angle bracket in text |
| &gt; | greater-than | Safer closing angle bracket in text |
| &amp; | ampersand | When you need an and-sign as text |
| &nbsp; | non-breaking space | Keep words or a label and number on one line |
| &quot; | quotation mark | Quote character when needed |
| &copy; | copyright | Copyright symbol |
Reserved characters in sentences
When you teach or mention tags in a normal paragraph, show them with entities so they stay text.
Entities in a sentence
html<p>Write <p> for a paragraph tag, and use & between names: Tom & Jerry.</p>
Reading the sample
<p>displays as the characters<p>without creating a paragraph element thereTom & Jerrydisplays as Tom & Jerry- A raw
&without a valid entity can cause parsing problems - Normal letters like
pandJerrydo not need entities
Non-breaking spaces
is a space that browsers should not use as a soft wrap point between the parts it joins. It is useful for keeping a short label with a number, or words you want to stay together. Do not sprinkle it everywhere as a layout tool — prefer normal spaces and CSS for real design.
Non-breaking space
html<p>Chapter 4 stays on one line more reliably than a normal space might.</p>
Named entities vs typing the symbol
For many symbols you can paste the real character if your file is saved as UTF-8 (see the Charset session later). Entities remain especially important for <, >, and & because those characters are part of HTML syntax. Learning the common named forms makes teaching pages and examples reliable across editors.
Practice in your editor
- Write a paragraph that shows the text
<div>using<and>. - Add a line with
AT&Twritten safely using&. - Use
between a short title and a number you do not want split across lines. - Open the page and confirm the symbols look correct.
- View source and find the entity codes — compare source vs rendered text.
- Intentionally forget a semicolon on one entity, reload, notice the odd result, then fix it.
Mistakes that break entities
- Forgetting
;at the end of an entity - Writing a lone
&in text that is not a complete entity (prefer&when you mean an ampersand) - Encoding ordinary letters and words that never needed entities
- Using
as a substitute for margin and layout instead of learning CSS spacing - Mixing up
<and>when showing tag examples
Summary
- Entities display reserved or special characters safely in HTML text
- Start with
<,>,&, and - Named entities begin with
&and end with; - Encode angle brackets and ampersands when they should appear as text
- Do not entity-encode normal prose letters without a reason
- Entities are especially handy when an HTML page teaches HTML
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top