Sams Teach Yourself HTML 4 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Tell Us What You Think!
- Put Your HTML Page Online Today
- I. Your First Web Page
- Hour 1. Understanding HTML and XML
- Hour 2. Create a Web Page Right Now
- Hour 3. Linking to Other Web Pages
- Hour 4. Publishing Your HTML Pages
- II. Web Page Text
- Hour 5. Text Alignment and Lists
- Hour 6. Text Formatting and Font Control
- Hour 7. Email Links and Links Within a Page
- Hour 8. Creating HTML Forms
- III. Web Page Graphics
- Hour 9. Creating Your Own Web Page Graphics
- Hour 10. Putting Graphics on a Web Page
- Hour 11. Custom Backgrounds and Colors
- Hour 12. Creating Animated Graphics
- IV. Web Page Design
- Hour 13. Page Design and Layout
- Hour 14. Graphical Links and Imagemaps
- Hour 15. Advanced Layout with Tables
- Hour 16. Using Style Sheets
- V. Dynamic Web Pages
- Hour 17. Embedding Multimedia in Web Pages
- Hour 18. Interactive Pages with Applets and ActiveX
- Hour 19. Web Page Scripting for Non-Programmers
- Hour 20. Setting Pages in Motion with Dynamic HTML
- VI. Building a Web Site
- Hour 21. Multipage Layout with Frames
- Hour 22. Organizing and Managing a Web Site
- Hour 23. Helping People Find Your Web Pages
- Hour 24. Planning for the Future of HTML
- VII. Appendixes
- A. Readers' Most Frequently Asked Questions
- B. HTML Learning Resources on the Internet
- C. Complete HTML 4 Quick Reference
- D. HTML Character Entities
XHTML, the New HTML
XML does pose a few problems, not the least of which is that the HTML and XML standards are almost—but not quite—compatible with one another. To smooth out these technical bumps, the W3C created a 100 percent XML-compliant version of HTML 4, called (you guessed, didn't you?) XHTML 1.
(Does that mean there will never be an HTML 5 standard? Sort of. There will undoubtedly be more tags and attributes added to HTML in the future, but the result will probably be called XHTML 2 instead of HTML 5.)
The most important thing for you to know about XHTML? How to write your Web pages for compatibility with it, while still remaining compatible with HTML-based Web browsers. If you learned HTML from this book, you have nothing to worry about because every example in the book and on the accompanying Web site (http://24hourHTMLcafe.com) is fully compatible with both HTML 4 and XHTML 1. If you have some older HTML pages that you need to convert for XHTML and XML compatibility, the following checklist will get you there:
- In HTML, it doesn't matter whether tags are uppercase, lowercase, or a mixture of both. In XHTML, all tags must be lowercase. For example, use <body> instead of <BODY>.
- Closing tags are often optional in HTML, but are always required in XHTML for any tag that encloses (refers to) some content. For example, every paragraph must begin with a <p> tag and end with a </p> tag. Likewise, every <li> list item must have a closing </li>, every <td> table data cell must have a closing </td>, and so forth.
- HTML tags that don't enclose any content (such as <br>, <hr>, and <img>) must now contain a slash (examples: <br /> <hr /> <img src="pic.gif" />). This tells XHTML interpreters not to expect a closing tag.
- In XHTML, all attribute values must be enclosed in quotation marks. For example, <img src=pic.gif border=1> was valid HTML, but it must be written as <img src="pic.gif" border="1" /> to be valid XHTML.
- All attributes must have values in XHTML. For example, <input type="checkbox" checked> should technically now be written as <input type="checkbox" checked="checked">.
- For technical reasons (read: bizarre and confusing reasons we don't need to get into), XHTML uses <a id="AnchorName"></a> instead of <a name= "AnchorName"></a> to create a named anchor. (See Hour 7, "Email Links and Links Within a Page," if you don't quite remember what an anchor is.) This is the only direct contradiction between HTML 4 and XHTML 1, but it's easy enough to be compatible with both. Simply use <a id="AnchorName" name="AnchorName"> </a> . (This redundancy is a bit of a hassle to type, and to be honest I haven't strictly followed the rule on this one in some of the examples in this book or on my own Web sites, since I doubt anyone will ever actually write software that fails to recognize name as meaning the same thing as id in this context.)
-
Certain special characters are not allowed in HTML because in context it might be hard to tell if they were meant as part of a mark-up tag. XHTML forbids the same characters, but is much more strict about not allowing them to appear in embedded style sheets and scripts. The forbidden characters and the codes you must replace them with are shown in Table 24.1.
(This is another case where I deserve a little slap on the wrist for not following religiously; for clarity I have used the single quotation mark character instead of #39; in some of the JavaScript examples in this book.)
Table 24.1. Characters You Should Avoid Using in XHTML Pages
| Replace This… | With This… |
| &(ampersand) | & |
| "(quotation/inch mark) | " |
| <(open angle-bracket) | < |
| >(close angle-bracket) | > |
| [ (open square bracket) | [ |
| ] (closed square bracket) | ] |
| '(apostrophe/single-quote) | ' |
HTML Applications of the Future | Next Section

Account Sign In
View your cart