Being Prepared


More and more, computer application developers are choosing to create their applications using Web technology. Whereas just 10 years ago, schools were busy teaching their students how to write BASIC programs and type DOS commands at the appropriate prompts, now they are teaching students HTML and learning to browse the Internet is a requirement. Some schools even offer homework help on the Internet. The Internet and Web technology are not going away, and they are going to continue to grow and change.

Already we are seeing the emergence of cell phones, pagers, and other hand-held devices that can display some Internet sites. The release of the XML standard will enable the Internet to become available in any number of new media. That's why it is important to understand what you can do now to make sure that you aren't caught off guard the next time the standard changes.

Check Your Code

Microsoft and Netscape, the two largest competitors in the browser wars, continue to try and outdo each other with new browser features. Both browsers have been known to create new tags that work only on their own browser. If you use those tags when you are creating your Web site, you end up forcing your viewers to choose a browser, or lose important features that you intended to share with them. Don't put them in that position. You can use tools, such as NetMechanic (http://www.netmechanic.com), to ensure that your site is the best it can be.

Be sure to test your pages on different browsers and older browser versions. Not everyone uses the newest version of a browser and some older versions do not support as many tags. The Browser Photo feature at the NetMechanic site does this for a small fee. Figure 17.2 shows what you can expect from their service. For each site, Browser Photo tells you which browsers (and at what resolutions) the site was tested.

Figure 17.2. NetMechanic can test your pages for browser compatibility.


Use Correct Syntax

XHMTL must be well-formed; in other words, tags must be nested properly (see the "Nest Tags Properly" section later in this lesson) and tags must be closed. For example, if you forget to close your <li> (list item) tag within a <ul> (unordered or bulleted list), the browser knows that when you add the next <li> tag, you want the last one to close. In fact, you want all of your tags to close. In HTML, the following:

<ul> <li>One ring-y, ding-y</li> <li>Two ring-y, ding-ys</li> </ul>


is the same as this:

<ul> <li>One ring-y, ding-y <li>Two ring-y, ding-ys </ul>


and the same as this:

<UL> <LI>One ring-y, ding-y</LI> <LI>Two ring-y, ding-ys</LI> </UL>


and the same as this:

<ul> <Li>One ring-y, ding-y</Li> <LI>Two ring-y, ding-ys</li> </Ul>


With XHTML documents, browsers can differentiate between those examples. Only the first example is well-formed. Learn now to use the proper syntax for your documents and you won't find yourself reworking them later.

Tip

Did you notice in the examples that capitalization of the tags makes a difference in XHTML? It's all part of the syntax.


Always Quote Attributes

All tag attributes must be quoted. In the past, you could add attributes, as in the following HTML sample:

<img src=/images/trial/gavel.jpg />


However, the new XHTML standard (in an effort to prepare us for the transition to XML) requires us to enclose all the attribute specifications in quotes, as in the following HTML sample:

<img src="/books/1/174/1/html/2//images/trial/gavel.jpg" />


These are minor differences, sure, but if you get into the habit of doing this correctly from the start, it will save a tremendous amount of rework as the standard is fine-tuned.

Use Style Sheets

In previous versions of HTML, Web page authors controlled the color, format, and layout of their documents with formatting tags (such as <font color="color" size="size" family="font name"> and <body bgcolor="color">). With XHTML, the W3C is recommending that all these format attributes be controlled with style sheets instead.

This book has focused on the XHTML preferences, which might mean that older browsers won't always show what you intend. You can add older HTML tags to your documents without affecting your style sheets, as shown in Figure 17.3. Just remember that the HTML format tags and the style sheet properties cannot conflict, or you will have problems. If your style sheet property tells the browser that the <body> tag should have a yellow background, for example, be sure that the <body> tag also calls for a yellow background. If you choose conflicting attributes by mistake (as is done in the following example where the style sheet requires the background color to be #FFFF80, but the <body> tag requires the background color to be white), the style sheet property takes precedence.

Figure 17.3. The HTML document seen earlier now has formatting tags added for older browsers.


Nest Tags Properly

Because XHTML and XML are more structured than HTML, you should get into the habit of paying attention to the details. You've seen in previous lessons that you can nest one HTML tag inside another. If you want to have text within a table cell (or any tagged element, such as a <ul>, <li>, and so on) to be both bold and italic, remember to close the tags in the opposite order from which they were opened. The following example shows that <b> was opened first and closed last.

<table> <tr> <td> <b>This text is only bolded. <i>This text is bolded and italicized.</i></b> </td> </tr> </table>


As shown above, you might nest tags within a paragraph. In that code, the two sentences are both bold, although only the second is also italicized.

Check It Twice

It's such a simple thing that we often overlook it, but your pages appear more professional and your visitors have more respect for the information you provide, if your content is spelled correctly.

By the same token, don't publish broken links. Nothing is worse than clicking a link that goes nowhere, or leads to the dreaded 404 error. Make sure you verify that all your links go where you want them to go.

Caution

Whatever you do, don't forget to verify that your document includes the correct DTD: Strict, Transitional, or Frameset. The document is not XHTML-compliant if it doesn't include the DTD.


Learn All You Can

The Internet is a great place to learn about HTML, XML, and the World Wide Web. Check out some of the following great resources:

  • W3C's HTML and XHTML Specifications www.w3.org/MarkUp/

  • W3C's XML 1.0 Recommendation www.w3.org/XML/

  • XML, Java, and the Future of the Web http://www.ibiblio.org/pub/sun-info/standards/xml/why/xmlapps.htm

  • XML Resource Center www.xml.com

  • W3 Schools http://www.w3schools.com/default.asp

In this lesson, you've learned:

  • XML goes beyond HTML. Rather than just assigning a structure to the text (with paragraphs, headings, tables, and so on), XML adds meaning and order.

  • The XML standard isn't complete yet, but it will take over the Internet when it is.

  • There are things you can do now to ensure that you are ready for the future of the Internet: use the correct syntax for all tags, use lowercase HTML tags, nest your tags appropriately, and use style sheets rather than the HTML formatting codes.



Sams Teach Yourself HTML in 10 Minutes
Sams Teach Yourself HTML in 10 Minutes (4th Edition)
ISBN: 067232878X
EAN: 2147483647
Year: 2004
Pages: 151
Authors: Deidre Hayes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net