Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML Entities

HTML entities are strings that display special characters on a web page.

Special characters include reserved chararacters, like euro € and delta Δ.

Also included are non-keyboard characters such as, copyright © and section §

An HTML entity begins with an ampersand (&) and ends with a semicolon (;)

Example

#

This example displays a british pound sign (£), angled brackets (< and >), and a copyright symbol (©).
They are created with the &pound; , &lt; , &gt;, and &copy; entities.

£ < > ©

<p style='font-size:50px;'>&pound; &lt; &gt; &copy;</p>

Why use HTML Entities?

Web pages use HTML markup which makes extensive use of < and > characters.

This means < and > cannot be used in content because it would confuse the browser.

HTML Entities solve this by using &lt; and &gt; which display as < and >.

In addition, many characters are not available on keyboards, such as the greek gamma character.

HTML Entities also solves this by using &gamma; which displays as γ.

What is a non-breaking space?

A common HTML entity used in web pages is the non-breaking space: &nbsp;

A non-breaking space is a space that will not break into a new line.

Two words separated by a non-breaking space will stick together.

They will not break even when there are space constraints.

This feature is important when breaking the words might be disruptive, such as '10 mph', '20 pixels'. The &nbsp; makes these non-breaking. Here are some examples.

10 km/h
10 PM
§ 10
845.65 USD
<div>10&nbsp;km/h</div>
<div>10&nbsp;PM</div>
<div>§&nbsp;10</div>
<div>845.65&nbsp;USD</div>

Tip:  Another common use of &nbsp; is to prevent browsers from collapsing spaces in text. Browsers collapse multiple spaces into a single space, but not the &nbsp; characters.


Other HTML Character Entities

This table lists some of the commonly used HTML character entities.

Result Description Entity Name Entity Number
non-breaking space &nbsp; &#160;
< less than &lt; &#60;
> greater than &gt; &#62;
& ampersand &amp; &#38;
" double quotation mark &quot; &#34;
' single quotation mark (apostrophe) &apos; &#39;
¢ cent &cent; &#162;
£ pound &pound; &#163;
¥ yen &yen; &#165;
euro &euro; &#8364;
© copyright &copy; &#169;
® registered trademark &reg; &#174;
Note:  Not all HTML Entities have an entity name. If that is the case you use the entity number.

For a complete list see our HTML Entities Reference.
A related list is our HTML Symbols Reference.


What are Diacritical Marks?

A diacritical mark is a glyph (little accent) added to a letter.

Some diacritical marks, like grave ( ̀  ) and acute ( ́  ) are called accents.

Diacritical marks can appear both above and below a letter, inside a letter, and between two letters.


Mark Character Construct Result
̀ a a&#768;
́ a a&#769;
̂ a a&#770;
̃ a a&#771;
̀ O O&#768;
́ O O&#769;
̂ O O&#770;
̃ O O&#771;

Diacritical marks can be placed on alphanumeric characters to produce a new character that is not present in the character set (i.e. encoding) used on the page. Essentially, two characters are combined into one new character.


You may also like


Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides