HTML entities are special codes used to display reserved characters or symbols in HTML that would otherwise be interpreted as part of the markup.
Why HTML Entities are Needed
- Certain characters like
<,>,&are reserved in HTML. - Using them directly may break the HTML structure.
- HTML entities encode these characters so they are displayed correctly in the browser.
Syntax
&entity_name; <!-- Named entity -->
&#entity_number; <!-- Numeric entity -->
Common HTML Entities
| Character | Entity Name | Entity Number |
|---|---|---|
< |
< |
< |
> |
> |
> |
& |
& |
& |
" |
" |
" |
' |
' |
' |
| Non-breaking space | |
  |
Example
<p>Display less than < and greater than > symbols.</p>
<p>Use & for ampersand symbol.</p>
Output in Browser:
Display less than < and greater than > symbols.
Use & for ampersand symbol.
💡 In Short:
HTML entities let you display reserved characters or special symbols in HTML safely without breaking the page structure.