Nearby lessons

20 of 24

πŸ”€ HTML Entities

πŸ“Œ What are HTML Entities?

HTML entities are used to represent characters that cannot be typed directly or may conflict with HTML syntax. πŸ€–

For example, '<' must be written as &lt; so the browser doesn't confuse it with a tag.

HTML entities are codes that start with an ampersand (&) and end with a semicolon (;), used to display characters that would otherwise be interpreted as HTML syntax.

πŸ“‹ Common HTML Entities

AttributeDescription
&nbsp;Non-breaking Space
&lt;Less Than
&gt;Greater Than
&amp;Ampersand
&quot;Double Quote
&#39;Single Quote
&copy;Copyright Symbol
&reg;Registered Trademark
&euro;Euro Symbol
&pound;Pound Symbol
&yen;Yen Symbol
&cent;Cent Symbol

πŸ§ͺ HTML Entities Example

Code Example
PREVIEW READY
Loading Editor...
Live Preview

βœ… Best Practices

  • βœ… Use named entities when available for readability
  • πŸ”’ Prefer numeric entities for obscure characters
  • ⚠️ Encode reserved characters like <, >, &, ", and ''
  • 🌐 Use UTF-8 encoding when possible
  • πŸ§ͺ Test rendering across browsers

🌍 Unicode Characters

With UTF-8 encoding, you can directly use Unicode characters in HTML. However, entities are useful for:
βœ”οΈ Compatibility
βœ”οΈ Clarity
βœ”οΈ When your keyboard doesn’t support certain characters

🧠 Test Your Knowledge

4 Questions

Progress: 0 / 4
Keep Going!HTML NBSP