HTML Special Characters
Learn how to display reserved characters, symbols, spaces, currency signs, and other special characters correctly in HTML.
What are HTML Special Characters?
Some characters have a special meaning in HTML.
For example, the less-than sign
< is used to begin an HTML tag.
When you need to display such characters as normal text, HTML character references can be used.
<
HTML Character References
Special characters can be represented using character
references. A character reference commonly starts with
& and ends with ;.
<
>
&
"
©
The browser interprets these references and displays the corresponding characters.
Less Than Symbol
The less-than symbol is written as:
<
Example
<p>
5 < 10
</p>
5 < 10
Greater Than Symbol
The greater-than symbol can be written as:
>
Example
<p>
10 > 5
</p>
10 > 5
Ampersand Symbol
The ampersand symbol is represented using:
&
Quotation Mark
The double quotation mark can be represented using:
"
Example
<p>
He said "Hello".
</p>
He said "Hello".
Non-Breaking Space
The character reference represents
a non-breaking space.
It creates a space that the browser does not normally collapse with adjacent spaces and keeps the words together across a line break.
Example
<p>
CIIT Institute
</p>
CIIT Institute
Copyright Symbol
©
Example
<p>
© CIIT Institute
</p>
© CIIT Institute
Registered Trademark Symbol
®
Example
<p>
CIIT®
</p>
CIIT®
Trademark Symbol
™
Example
<p>
CIIT™
</p>
CIIT™
Currency Symbols
HTML can display a wide range of currency symbols using character references or Unicode characters.
| Symbol | Reference | Output |
|---|---|---|
| Rupee |
₹
|
₹ |
| Dollar |
$
|
$ |
| Euro |
€
|
€ |
| Pound |
£
|
£ |
| Yen |
¥
|
¥ |
Mathematical Symbols
| Symbol | Reference | Output |
|---|---|---|
| Less Than |
<
|
< |
| Greater Than |
>
|
> |
| Plus/Minus |
±
|
± |
| Multiplication |
×
|
× |
| Division |
÷
|
÷ |
| Not Equal |
≠
|
≠ |
| Less Than or Equal |
≤
|
≤ |
| Greater Than or Equal |
≥
|
≥ |
Arrow Symbols
| Symbol | Reference | Output |
|---|---|---|
| Left Arrow |
←
|
← |
| Right Arrow |
→
|
→ |
| Up Arrow |
↑
|
↑ |
| Down Arrow |
↓
|
↓ |
| Left-Right Arrow |
↔
|
↔ |
Other Common Special Characters
| Character | Reference | Result |
|---|---|---|
| Cent |
¢
|
¢ |
| Section |
§
|
§ |
| Degree |
°
|
° |
| Paragraph |
¶
|
¶ |
| Bullet |
•
|
• |
| Middle Dot |
·
|
· |
Numeric Character References
Characters can also be represented using numeric character references.
©
®
₹
© Copyright
® Registered
₹ Indian Rupee
Hexadecimal Character References
Unicode characters can also be represented using hexadecimal numeric references.
€
€
The example above represents the Euro symbol.
Example in an HTML Page
<!DOCTYPE html>
<html>
<head>
<title>
Special Characters
</title>
</head>
<body>
<p>
5 < 10
</p>
<p>
CIIT © Institute
</p>
<p>
Price: ₹4500
</p>
<p>
HTML → CSS → JavaScript
</p>
</body>
</html>
Output
5 < 10
CIIT © Institute
Price: ₹4500
HTML → CSS → JavaScript
Important Rules
-
Character references normally begin with
&. -
Named references usually end with
;. - Use character references when a character could be interpreted as HTML markup.
- Numeric character references can represent Unicode characters.
- Always choose the correct character reference for the character you want to display.
Common Mistakes
-
Writing
<directly when it should be interpreted as text. - Forgetting the semicolon at the end of a named character reference.
- Using an incorrect character reference.
- Confusing HTML character references with CSS escape sequences or programming-language escapes.
Practice Exercise
-
Display
<and>as normal text. -
Display an ampersand using
&. - Display a copyright symbol.
- Display the Indian Rupee symbol.
- Display a right arrow.
- Create a small HTML page containing at least five different special characters.
Summary
HTML character references are used to display special
characters and symbols safely in HTML. Common examples
include <, >,
&, ©,
®, and .
Numeric and hexadecimal references can also be used
to represent Unicode characters.