HTML Entities

HTML entities are used to display reserved characters and special symbols that cannot be written directly in HTML. They ensure that browsers correctly render characters like <, >, and non-breaking spaces without confusing them with HTML markup.

On this page

HTML Entities

HTML entities are used to display reserved characters and special symbols that cannot be written directly in HTML.

Some characters, such as < and >, are reserved because they are used to define HTML tags.

Reserved Characters

If reserved characters are written directly in HTML text, the browser may interpret them as markup.

For example, the less-than and greater-than signs must be replaced with entities:

< = &lt; > = &gt;

Entity Names and Numbers

HTML entities can be written using either an entity name or an entity number.

Entity names are easier to read and remember:

&lt; &gt;

Entity numbers use numeric codes:

< >

Non-breaking Space

The non-breaking space entity &nbsp; prevents automatic line breaks between words.

This is useful for keeping related text together, such as units or abbreviations.

10 km/h 10 PM § 10

It can also be used to preserve multiple spaces, which are normally collapsed by the browser.

Common HTML Character Entities

Character Description Entity Name Entity Number
< Less than &lt; <
> Greater than &gt; >
& Ampersand &amp; &
" Double quote &quot; "
© Copyright &copy; ©
Euro &euro;

Note: Entity names are case sensitive.

Combining Diacritical Marks

Diacritical marks are symbols added to letters to change their pronunciation or meaning.

They can be combined with characters using entity numbers to produce accented letters:

à → à á → á â → â ã → ã

This method is useful when a specific character is not directly available in the page encoding.

HTML Entities Examples (6)