HTML, XHTML, & CSS(c) Visual QuickStart Guide
Authors: Castro E.
Published year: 2004
Pages: 18-19/340
Buy this book on amazon.com >>

A Web Page's Text Content

The text contained within elements is perhaps a Web page's most basic ingredient. If you've ever used a word processor, you've typed some text. Text in an (X)HTML page, however, has some important differences.

First, (X)HTML collapses extra spaces or tabs into a single space and either converts returns and line feeds into a single space or ignores them altogether (Figures 1.10 and 1.11) .

Figure 1.10. The text content is basically anything outside of the markup. Note that each line happens to be separated with a carriage return. Also, I've used a special character reference © for the copyright symbol to ensure that it is properly displayed no matter how I save this document.


Figure 1.11. Note how the extra returns are ignored when the document is viewed with a Web browser and the character reference is replaced by the corresponding symbol ().


Next, HTML used to be restricted to ASCII charactersbasically the letters of the English language, numerals, and a few of the most common symbols. Accented characters (common to many languages of Western Europe) and many everyday symbols had to be created with special character references like é (for ) or © (for ).

Nowadays, you have two options. Although you can still use character references, it's often easier to simply type most characters as they are and then encode your (X)HTML files in Unicode (and particularly with UTF-8). Because Unicode is a superset of ASCIIit's everything ASCII is, and a lot moreUnicode-encoded documents are compatible with existing browsers and editors. Browsers that don't understand Unicode will interpret the ASCII portion of the document properly, while browsers that do understand Unicode will display the non-ASCII portion as well. (For more details, see Chapter 21, Symbols and Non-English Characters .)

The only symbol that you must not type in directly is the & . Since it has special meaning in (X)HTML, namely to begin those character references, it must always be expressed as & when used as text, as in AT&T . For more details, consult Adding Characters from Outside the Encoding on page 336.



Links, Images, and Other Non-Text Content

Of course, what makes the Web so vibrant are the links from one page to another, the images, Flash animations, QuickTime movies, MP3 songs, and more. Instead of actually enclosing the external files in the (X)HTML file, these files are saved independently and are simply referenced from within the page. Since the reference is nothing more than text, the (X)HTML file remains universally accessible.

Figure 1.12. In this (X)HTML document, there is a reference to a file called tigerlily.jpg , which the browser will access, open , and load when it loads the rest of the page.


Most browsers can handle links and images without much trouble. They can't necessarily handle every other kind of file, however. If you reference a file that your visitor's browser doesn't understand, the browser will usually try to find a plugin or helper application some appropriate program on the visitor's computerthat is capable of opening that kind of file. You can also give browsers extra information about how to download plugins for viewing particular files if the visitor doesn't already have one on their computer.

We'll cover images in Chapter 5, Images , and go over plugins and helper applications in Chapter 18, Video, Audio, and other Multimedia .

Figure 1.13. Images, and other non-text content, are referenced from a Web page and the browser displays them together with the text.



HTML, XHTML, & CSS(c) Visual QuickStart Guide
Authors: Castro E.
Published year: 2004
Pages: 18-19/340
Buy this book on amazon.com >>

Similar books on Amazon