ptg16476052
140 LESSON 7: Formatting Text with HTML and CSS
make sure that your pages specify that they are encoded in UTF-8 and that you use the
entities that I’ll describe shortly for any characters that are not in the 128 characters in
the ASCII set. If you do both of those things, you’ll never run into problems with brows-
ers not displaying the characters that you intend.
UTF-8 is a character set that’s backward compatible with ASCII
and that supports every character in the Unicode character set.
This is important because Unicode supports a huge number of
characters in a large number of alphabets. It’s extremely unlikely
that you would ever want to use a character that is not supported
by Unicode.
NOTE
The question is, how do you specify that your web pages use the UTF-8 character set?
The character set can be configured at the web server level, and I’ll discuss that in Lesson
23, “How to Publish Your Site.” You can specify the encoding at the page level. If you
are using HTML5, you should begi n your page like this:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
The character set is specified using the <meta> tag. For HTML5, the character set is spec-
ified using the following <meta> tag:
<meta charset="utf-8">
UTF-8 was created to provide a single character set that would encompass the huge num-
ber of characters used in various languages around the world, and it should be used for all
web pages unless there is a very good reason not to.
Character Entities for Special Characters
Character entities take one of two forms: named entities and numbered entities.
Named entities begin with an ampersand (&) and end with a semicolon (;). In between
is the name of the character (or, more likely, a shorthand version of that name, such
as agrave for an a with a grave accent, or reg for a registered trademark sign). Unlike
other HTML tags, the names are case sensitive, so you should make sure to type them in
exactly. Named entities look something like the following:
à
"