1. HTML Entities
HTML entities are used to display characters that are reserved in HTML, ensuring they appear correctly in the browser. They are also used for characters that cannot be typed directly in HTML.
Why Use HTML Entities?
- To display reserved characters like
<
,>
, and&
. - To show non-keyboard characters like
©
,®
, and€
.
Structure of an HTML Entity:
- Begins with
&
and ends with;
. - Example:
<
represents<
.
Common HTML Entities:
<
:<
(less than)>
:>
(greater than)&
:&
(ampersand)"
:"
(double quote)'
:'
(apostrophe)
Example Usage:
<p>Use < and > for angle brackets in HTML.</p>
This will display as:
Use < and > for angle brackets in HTML.
2. HTML Symbols
HTML symbols are characters or icons that are not found on a standard keyboard. These symbols can represent various objects, currencies, or concepts.
Common HTML Symbols:
©
: © (copyright)®
: ® (registered trademark)€
: € (Euro sign)£
: £ (Pound sign)¥
: ¥ (Yen sign)
Example Usage:
<p>© 2025 YourCompany. All rights reserved.</p>
This will display as:
© 2025 YourCompany. All rights reserved.
3. HTML Emojis
Emojis are graphical symbols used to convey emotions, objects, or ideas. They are widely supported in modern browsers and can be included in HTML using Unicode or direct input.
How to Use Emojis in HTML:
- Use Unicode values for emojis, usually represented in HTML as
&#X;
whereX
is the Unicode number.
Common Emojis:
😀
: 😀 (grinning face)💙
: 💙 (blue heart)👍
: 👍 (thumbs up)🎉
: 🎉 (party popper)🌞
: 🌞 (sun)
Example Usage:
<p>Welcome to our website! 😀</p> <p>We hope you have a great day! 🌞</p>
This will display as:
Welcome to our website! 😀
We hope you have a great day! 🌞
Practical Examples
Using HTML Entities, Symbols, and Emojis Together
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML Entities, Symbols, and Emojis</title> </head> <body> <h1>HTML Entities</h1> <p>Use <strong> for bold text in HTML.</p> <h1>HTML Symbols</h1> <p>Currency Symbols: Euro €, Pound £, Yen ¥.</p> <h1>HTML Emojis</h1> <p>Celebrate with us! 🎉 😃</p> </body> </html>
Result:
- HTML Entities: “Use
<strong>
for bold text in HTML.” - HTML Symbols: “Currency Symbols: Euro €, Pound £, Yen ¥.”
- HTML Emojis: “Celebrate with us! 🎉 😃”
Conclusion
HTML entities, symbols, and emojis help in displaying a wide range of characters and expressions that enhance the readability and visual appeal of your web pages. They ensure that reserved characters are properly rendered and allow for creative and dynamic content through symbols and emojis.
By mastering these elements, you can:
- Safely include special characters in your HTML content.
- Enrich your web pages with symbols and emojis to better engage users.