0% found this document useful (0 votes)
20 views2 pages

09 Somespecialcharacters

Uploaded by

amogz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

09 Somespecialcharacters

Uploaded by

amogz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

some special Characters

some special Characters


There’s just one more text-related topic before we close this chapter out.
Some common characters, such as the copyright symbol ©, are not part of
the standard set of ASCII characters, which contains only letters, numbers,
and a few basic symbols. Other characters, such as the less-than symbol (<),
are available, but if you put one in an HTML document, the browser will
interpret it as the beginning of a tag.
Characters such as these must be escaped in the source document. Escaping
means that instead of typing in the character itself, you represent it by its
numeric or named character reference. When the browser sees the character
reference, it substitutes the proper character in that spot when the page is
displayed.
There are two ways of referring to a specific character: by an assigned
numeric value (numeric entity) or using a predefined abbreviated name for
the character (called a named entity). All character references begin with an
“&” and end with a “;”.
Some examples will make this clear. I’d like to add a copyright symbol to my
page. The typical Mac keyboard command, Option-G, which works in my n oT e
word processing program, may not be understood properly by a browser or In XHTML, every instance of an amper-
other software. Instead, I must use the named entity &copy; (or its numeric sand must be escaped so that it is not
equivalent, &#169;) where I want the symbol to appear (Figure 5-17). interpreted as the beginning of a char-
acter entity, even when it appears in the
<p>All content copyright &copy; 2012, Jennifer Robbins</p> value of an attribute. For example:
or: <img src="sno.jpg" alt="Sifl
&amp; Olly Show" />
<p>All content copyright &#169; 2012, Jennifer Robbins</p>

HTML defines hundreds of named entities as part of the markup language,


which is to say you can’t make up your own entity. Table 5-2 lists some com-
monly used character references. If you’d like to see them all, the complete
list of character references has been assembled online by the nice folks at
the Web Standards Project at www.webstandards.org/learn/reference/charts/
entities/.

Figure 5-17. The special character is substituted for the character reference when the
document is displayed in the browser.

1
some special Characters

Table 5-2. Common special characters and their character references

Character Description Name Number


Character space (nonbreak- &nbsp &#160;
ing space)
Non-breaking & Ampersand &amp; &#038;
spaces ‘ Apostrophe &apos; &#039;
One interesting character to know < Less-than symbol (useful for &lt; &#060;
about is the non-breaking space
displaying markup on a web
(&nbsp;). Its purpose is to ensure that
page)
a line doesn’t break between two
words. So, for instance, if I mark up > Greater-than symbol (useful &gt; &#062;
my name like this: for displaying markup on a
web page)
Jennifer&nbsp;Robbins
© Copyright &copy; &#169;
I can be sure that my first and last
names will always stay together on ® Registered trademark &reg; &#174;
a line. ™ Trademark &trade; &#8482;
£ Pound &pound; &#163;
¥ Yen &yen; &#165;
€ Euro &euro; &#8364;
– En-dash &ndash; &#8211;
— Em-dash &mdash; &#8212;
‘ Left curly single quote &lsquo; &#8216;
’ Right curly single quote &rsquo; &#8217;
“ Left curly double quote &ldquo; &#8220;
” Right curly double quote &rdquo; &#8221;
• Bullet &bull; &#8226;
... Horizontal ellipsis &hellip; &#8230;

Remember that indenting each


hierarchical level in your HTML source
consistently makes the document
easier to scan and update later.

You might also like