- HTML Tutorial
- HTML Introduction
- HTML Editors
- HTML Basic
- HTML Comments
- HTML Elements
- HTML Attributes
- HTML Id & Classes
- HTML Skeletal Tags
- HTML Heading Tags
- HTML Paragraph Tag
- HTML Line Break Tag
- HTML Pre Tag
- HTML Anchor Tag
- HTML Image Tag
- HTML Horizontal Line Tag
- HTML Inline & Block
- HTML Inline
- HTML Block
- HTML LInks
- HTML Images
- HTML Formatting
- HTML Head
- HTML Head
- HTML Title
- HTML Meta Elements
- HTML Favicon
- HTML Style
- HTML List
- HTML Lists
- HTML Unordered List
- HTML Ordered List
- HTML Description List
- HTML Table
- HTML Tables
- HTML Table Headers
- HTML Table Styling
- HTML Table Colgroup
- HTML Form
- HTML Forms
- HTML Form Elements
- HTML Form Attributes
- HTML Input Types
- HTML Input Attributes
- HTML Form Actions
- HTML Semantic
- HTML Semantics
- HTML Graphics & Media
- HTML Canvas
- HTML SVG
- HTML Video & Audio
- HTML Plug-ins
- iFrames in HTML
- HTML Miscellaneous Tags
- HTML Code Tag
- HTML Entities
- HTML Quotation
- HTML Global Attributes
- HTML Obsolete Tags
- HTML Emojis
- HTML Symbols
- HTML Events
- HTML Colors
HTML Entities
HTML entities are specialized strings of text used to display characters that are either reserved by the HTML language or difficult to type on a standard keyboard. Because browsers interpret characters like < and > as the start and end of tags, using them directly in your content can lead to "tag collision," where the browser tries to parse your text as code, often breaking the page layout.
Syntax
An HTML entity always follows a specific pattern: it starts with an ampersand (&) and ends with a semicolon (;). In between, you can use either a descriptive name or a unique decimal/hexadecimal number.
Syntax:
&entityName;
or
&#entityNumber;
©) whenever possible because they are much easier for humans to read and remember. Use Entity Numbers only when a named entity doesn't exist for the character you need.
Commonly Used HTML Entities
Understanding when to use entities is key to building robust, bug-free web pages. Here are the most common categories you will encounter in professional development.
1. Reserved Characters
Certain characters are "reserved" because they have functional roles in HTML. If you want to display the text <script> on a page without actually running a script, you must use entities.
&) in URLs or text. If you write "Sales & Marketing," some older browsers or validators might get confused, thinking the & is the start of a broken entity. Always use &.
Example 1: Display Reserved Characters
The following example shows how to safely display code snippets or reserved symbols within your UI.
<!DOCTYPE html>
<html>
<head>
<title>HTML Entities Example</title>
</head>
<body>
<p>Displaying code snippets safely:</p>
<ul>
<li>The &amp; entity displays: &</li>
<li>To show a tag like <div>, use &lt; and &gt;.</li>
<li>Quote marks in attributes: &quot;Sample&quot; becomes "Sample"</li>
</ul>
</body>
</html>
2. Mathematical Symbols
Standard keyboards lack most mathematical operators. HTML entities provide a clean way to display equations without relying on external images or complex fonts.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Math Symbols with HTML Entities</title>
</head>
<body>
<p>Equation Examples:</p>
<ul>
<li>Temperature variation: 10°C ± 2°</li>
<li>Calculation: 5 × 10 ÷ 2 = 25</li>
<li>Area of a circle: A = πr²</li>
</ul>
</body>
</html>
3. Currency Symbols
When building e-commerce sites or financial dashboards, you often need to support multiple global currencies. Using entities ensures these symbols render correctly regardless of the user's OS or installed fonts.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Currency Example</title>
</head>
<body>
<p>Product Pricing:</p>
<ul>
<li>US Price: $19.99</li>
<li>EU Price: €17.50</li>
<li>UK Price: £15.00</li>
<li>Japan Price: ¥2500</li>
</ul>
</body>
</html>
4. Special Characters
This category includes typographical marks like the copyright symbol, arrows for navigation, and bullets for custom list styling.
(Non-Breaking Space). Use it when you want to prevent the browser from breaking a line between two words, such as "10 km".
Example:
<!DOCTYPE html>
<html>
<head>
<title>Special Characters Example</title>
</head>
<body>
<footer>
<p>© 2026 rJTutorial. All Rights Reserved ®</p>
<p>View More →</p>
</footer>
</body>
</html>
5. Emoji Entities
Emojis are actually part of the Unicode standard. You can display them using their decimal entity codes. This is useful for adding visual flair without loading heavy image files.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Emoji Example</title>
</head>
<body>
<p>Using Decimal Codes for Emojis:</p>
<p>Great job! 👍</p>
<p>Success! 🎉</p>
<p>System Alert: ⚠</p>
</body>
</html>
Summary
HTML entities are an essential tool for any web developer. They prevent the browser from misinterpreting reserved characters, solve the problem of missing keyboard symbols, and ensure that your content looks exactly as intended across all devices. By consistently using named entities for reserved characters and numerical codes for special symbols or emojis, you can write cleaner, more professional HTML code.