Loading...

HTML Entities Reference

HTML Entities are a fundamental part of writing clean, readable, and valid HTML—especially when you need to display characters that either have special meaning in HTML or are not readily available on a standard keyboard. The HTML Entities Reference is like a well-organized index in a library; it gives you access to reserved characters like <, >, and &, as well as symbols like ©, , , and more.
You’ll encounter the need for HTML entities in nearly every web project. In a portfolio website, you might want to display angle brackets around code; in a blog, you might show quotes or dashes properly; in an e-commerce site, currency symbols like ¥ or are essential; news sites often use entities for editorial marks; and social platforms use them to sanitize user input and prevent code injection.
In this reference, you’ll learn what HTML entities are, how to use them, and which ones are essential for real-world web development. Think of it as decorating a room—you want everything in its place, displayed correctly, and structured so that both humans and machines can interpret it properly. This guide is your toolkit for getting every symbol right.

Basic Example

html
HTML Code
<!-- Display special characters using HTML entities -->

<!DOCTYPE html>

<html>
<body>
<p>5 &lt; 10 &amp;&amp; 10 &gt; 5</p>
<p>&copy; 2025 My Blog</p>
</body>
</html>

This basic example demonstrates the use of HTML entities to correctly display special characters in a browser. Here's a breakdown:

  • &lt; represents the less-than symbol <.
  • &gt; represents the greater-than symbol >.
  • &amp; displays the ampersand &.
  • &copy; outputs the copyright symbol ©.
    These characters are reserved in HTML syntax and would otherwise be interpreted as part of the markup. For instance, if you use < without an entity, the browser may interpret it as the start of an HTML tag, potentially breaking your page layout. By using entities, you ensure that the text appears as intended and is safe from misinterpretation by the browser.
    This practice is especially important in content-heavy environments like news sites or blogs, where quotes, symbols, or mathematical operators are common. It also prevents security vulnerabilities (like XSS) in platforms that accept user input. New developers might overlook entities, but mastering them leads to more semantic, accessible, and robust web pages.

Practical Example

html
HTML Code
<!-- Displaying symbols in an e-commerce product card -->

<!DOCTYPE html>

<html>
<body>
<h2>Wireless Earbuds</h2>
<p>Price: 149.99 &euro;</p>
<p>Rating: 4.5 &starf; / 5</p>
<p>In Stock: &check;</p>
</body>
</html>

This practical example shows how HTML entities enhance the user interface of an e-commerce product listing. Here’s how each entity works in a real-world context:

  • &euro; displays the Euro currency symbol (€), crucial for showing prices.
  • &starf; renders a solid star (★), useful for visualizing user ratings.
  • &check; adds a checkmark (✔), indicating availability or success.
    Using HTML entities instead of images or icon fonts keeps your markup lightweight and accessible. They scale well with different screen sizes and work reliably across browsers and devices. Additionally, screen readers interpret entities properly, enhancing accessibility for visually impaired users.
    This technique is also useful in social platforms to show symbols in posts or reactions, and in blogs to format editorial symbols or citations. The key is to understand that HTML entities are not decoration—they're precise communication tools that maintain the integrity and clarity of your content.

Best Practices:

  1. Use named entities for readability, like &copy; instead of &#169;. They’re easier to debug and remember.
  2. Ensure entities are properly terminated with a semicolon (;) to avoid rendering issues.
  3. Use entities for reserved characters in dynamic content to prevent HTML injection or breaking your DOM.
  4. Incorporate entities in semantic tags like <code>, <blockquote>, or <footer> for clean and meaningful markup.
    Common Mistakes:

  5. Forgetting the semicolon: Writing &copy instead of &copy; leads to incorrect output.

  6. Using non-standard or obsolete entities: Stick to valid, widely supported ones.
  7. Placing raw symbols directly in code: Using < in text can corrupt structure unless properly escaped.
  8. Relying on visual symbols without context: A symbol like &starf; without text can confuse screen reader users.
    Debugging Tips:
  • Use HTML validators to catch invalid or incomplete entities.
  • Preview content across multiple browsers and devices.
  • Use browser DevTools to inspect and verify rendered entities.

📊 Quick Reference

Entity Description Example
< Less-than sign 5 < 10
\> Greater-than sign 10 > 5
& Ampersand AT\&T
© Copyright © 2025
Solid star Rating: 5 ★
Check mark Status: ✓

Summary and Next Steps:
HTML entities are essential when working with content that includes special characters, reserved syntax, or symbols. They ensure that your content is displayed correctly, remains secure, and is accessible to all users, including those using assistive technology.
Understanding entities improves your ability to write semantic HTML, collaborate with other developers, and maintain consistency across browsers and platforms. This connects directly to CSS styling (as entities can appear inline or block) and JavaScript (as entities might be handled dynamically or from user input).
Next, consider studying:

  • CSS pseudo-elements for styling around symbols
  • Unicode basics and numeric character references
  • Escape and encode techniques in JavaScript for handling input/output
    Apply what you've learned by reviewing your existing projects for improper symbols and replacing them with proper HTML entities where necessary.

🧠 Test Your Knowledge

Ready to Start

Test Your Knowledge

Test your understanding of this topic with practical questions.

4
Questions
🎯
70%
To Pass
♾️
Time
🔄
Attempts

📝 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