Loading lessons...
HTML Entities
Some characters are special in HTML, and some can't be typed easily. HTML entities solve both problems!
What is an entity?
An entity is a special code that stands for a character. It starts with & and ends with ;.
Code
html
< stands for <
> stands for >
& stands for &
The big three you MUST know
If you write < or > directly in text, the browser might think you're writing a tag! Use entities instead:
Code
html
<p>2 is less than < 3</p>
<p>5 is greater than > 4</p>
<p>Tom & Jerry</p>
More useful entities
&quot;: double quote"&apos;(or&#39;): single quote'&nbsp;: a non-breaking space (keeps words together!)&copy;: copyright©&reg;: registered®&trade;: trademark™&euro;: euro sign€&pound;: pound sign£&yen;: yen sign¥
Non-breaking space (&nbsp;)
&nbsp; is a space that never lets the words split across lines. Use it to keep "10 km" or "Chapter 5" together.
Code
html
<p>It's about 10 km away.</p>
Number entities
You can also use numbers: &#65; is the character number 65, which is "A".
Code
html
<p>A is the letter A</p>
TL;DR
- Entities start with
&and end with;. - Use
&lt;,&gt;,&amp;for<,>,&. &nbsp;is a space that keeps words together.&copy;,&euro;,&reg;and friends type special symbols.- Number entities like
&#65;use character numbers.