5.1 Character Escaping
In HTML, special characters, also known as "character entities", are used to represent characters that would otherwise be interpreted as part of the HTML syntax. These characters include, for example, angle brackets, ampersand, spaces, and symbols from various languages and character sets.
Angle Brackets and Ampersand
To display characters that are used in HTML as part of a tag or syntax, you need to use special codes:
- < : <
- > : >
- & : &
Example of usage:
<p>Use < and > for angle brackets, and & for ampersand.</p>
Quotation Marks
For displaying double and single quotes within HTML attributes:
- " : "
- ' : '
Example of usage:
<p>For quotes, use "double" and 'single' quotes.</p>
5.2 Spaces and Non-breaking Spaces
In HTML multiple consecutive spaces always display as a single space. To preserve spaces or create non-breaking spaces, special characters are used:
- Space :
- Thin Space :  
- Full Space :  
- En Space :  
Example of usage:
<p>This text contains several non-breaking spaces.</p>
Special Characters and Diacritics
HTML supports a multitude of special characters for various languages and character sets. For example:
- © : ©
- ® : ®
- ™ : ™
- € : €
- £ : £
Example of usage:
<p>Copyright © 2024. All rights reserved. Price: 50 €</p>
Mathematical Symbols
HTML supports a wide set of mathematical symbols:
- ± : ±
- × : ×
- ÷: ÷
- ≤ : ≤
- ≥: ≥
- ∞ : ∞
- √ : √
Example of usage:
<p>Equation: x ≥ 5 and x ≤ 10. Use √ to denote a root.</p>
5.3 Arrows and Other Graphic Symbols
HTML also supports arrows and other graphic symbols:
- ← : ←
- ↑ : ↑
- → : →
- ↓ : ↓
- ↔ : ↔
- ♠ : ♠
- ♣ : ♣
- ♥ : ♥
- ♦ : ♦
Example of usage:
<p>Directions: ← left, ↑ up, → right, ↓ down.</p>
<p>Card suits: ♠ ♥ ♦ ♣</p>
Full List of Special Characters
A full list of special characters can be found in HTML documentation or on specialized web resources like W3Schools or HTML Character Entities Reference.
5.4 Using Emojis
Emojis have become an essential part of modern digital communication. They're used to express emotions, ideas, and objects in text messages, social media, and on web pages. In HTML, emojis can be used in several ways.
Using Unicode
Emojis can be inserted into an HTML document using Unicode symbols. Each emoji has a unique code that can be used to display it.
Example of using Unicode:
<p>Smiley face: 😀</p>
<p>Heart: ❤️</p>
<p>Thumbs up: 👍</p>
To insert an emoji using Unicode, you need to use its hexadecimal code, prefixed with &#x and closed with ;.
Example of using hexadecimal codes:
<p>Smiley face: 😀</p>
<p>Heart: ❤️</p>
<p>Thumbs up: 👍</p>
No need to memorize this stuff: just google them if necessary and don't freak out if you see them in someone else's code 😊
GO TO FULL VERSION