Reserved characters in HTML must be replaced with
character entities.
HTML Entities:
Some
characters are reserved in HTML.
It is not
possible to use the less than (<) or greater than (>) signs in your text,
because the browser will mix them with tags.
To
actually display reserved characters, we must use character entities in the
HTML source code.
A character entity looks like this:
&entity_name;
OR
&#entity_number;
To display
a less than sign we must write: < or <
Tip: The
advantage of using an entity name, instead of a number, is that the name is
easier to remember. However, the disadvantage is that browsers may not support
all entity names (the support for entity numbers is very good).
Non-breaking Space:
A common
character entity used in HTML is the non-breaking space ( ).
Browsers
will always truncate spaces in HTML pages. If you write 10 spaces in your text,
the browser will remove 9 of them, before displaying the page. To add spaces to
your text, you can use the character entity.
HTML Useful Character Entities:
Note: Entity names are case
sensitive!
Result
|
Description
|
Entity Name
|
Number
|
non-breaking space
|
|
 
|
|
<
|
less than
|
<
|
<
|
>
|
greater than
|
>
|
>
|
&
|
ampersand &
|
&
|
&
|
¢
|
Cent
|
¢
|
¢
|
£
|
pound
|
£
|
£
|
¥
|
yen
|
¥
|
¥
|
€
|
euro
|
€
|
€
|
§
|
section
|
§
|
§
|
©
|
copyright
|
©
|
©
|
®
|
registered trademark
|
®
|
®
|
™
|
trademark
|
™
|
™
|
£
|
English Pound
|
£
|
£
|
¤
|
Currency
|
¤
|
¤
|
°
|
Degree(s)
|
°
|
°
|
±
|
Plus or Minus
|
±
|
±
|
¼
|
¼ Fraction
|
¼
|
¼
|
½
|
½ Fraction
|
½
|
½
|
¾
|
¾ Fraction
|
¾
|
¾
|
html character entities:
An
"entity" is a fancy term for a symbol. Several symbols, such as
copyright, trademark, or foreign cash symbols, exist on your standard keyboard,
so you need to display these characters using a different method.
There are three
parts to every entity.
- Each begins with a ampersand - &
- Then the entities name - copy
- And finally a semicolon - ;
Copyright:
Combine
© to make - © - Copyright symbol.
Expect complications
if you forget to include all three parts of an entity.
Additional spaces and <>.
Regardless of how many spaces you place between words, your web browser will only render a single space. To get around this, use the non-breaking spacecharacter entity.
HTML Code:
<p>Everything that goes up, must come
down!</p>
Spaces:
Everything that goes up, must
come down!
In HTML, we use
less than and greater than characters to create tags, so to use them on your
website you will need entities.
HTML Code:
<p>
Less than - < <br />
Greater than - > <br />
Body tag - <body>
</p>
Less than Greater than:
Less than - <
Greater than - >
Body tag - <body>
No comments:
Post a Comment