home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeHTML & XHTML: The Definitive GuideSearch this book

4.10. Special Character Encoding

For the most part, characters within documents that are not part of a tag are rendered as is by the browser. However, some characters have special meaning and are not directly rendered, while other characters can't be typed into the source document from a conventional keyboard. Special characters need either a special name or a numeric character encoding for inclusion in a document.

4.10.2. Inserting Special Characters

To include a special character in your document, enclose either its standard entity name or a pound sign (#) and its numeric position in the Latin-1 standard character set[27] inside a leading ampersand and an ending semicolon, without any spaces in-between.

[27]The popular ASCII character set is a subset of the more comprehensive Latin-1 character set. Composed by the well-respected International Organization for Standardization (ISO), the Latin-1 set is a list of all letters, numbers, punctuation marks, and so on, commonly used by Western language writers, organized by number and encoded with special names. Appendix F, "Character Entities" contains the complete Latin-1 character set and encoding.

Whew. That's a long explanation for what is really a simple thing to do, as the following example illustrates. The example shows how to include a greater-than sign in a snippet of code by using the character's entity name. It also demonstrates how to include a greater-than sign in your text by referencing its Latin-1 numeric value:

if a > b, then t = 0
if a > b, then t = 0

Both examples cause the text to be rendered as:

if a > b, then t = 0

The complete set of character entity values and names are in Appendix F, "Character Entities". You could write an entire document using character encoding, but that would be silly.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.