Online Book Reader

Home Category

HTML, XHTML and CSS All-In-One for Dummies - Andy Harris [18]

By Root 1404 0
(I keep a copy on my Desktop) and begin all your new pages with this template. When you start to use a more complex editor (see Chapter 3 of this minibook), you can often customize the editor so that it automatically starts with the framework you want.

You don’t have to have all this stuff down cold, but you should understand the basics of what’s going on, so the following is a quick tour.


The DOCTYPE tag

The scariest looking XHTML feature is the tag. This monster is ugly, no doubt, but it does serve a purpose. Officially, it’s a document type definition. Your doctype declares to the world what particular flavor of HTML or XHTML you’re using. When you begin your page with the doctype that I suggest here, you’re telling the browser: “Hey, browser, my page follows the XHTML Strict guidelines, and if you aren’t sure what that is, go to this Web site to get it.”

“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

Many doctypes are available, but it’s really a lot simpler than it seems. In this book, I show you XHTML 1.0 Strict, which is the primary doctype you need today. The other variations you might find on the Web (HTML 4.0, Frameset, and Transitional doctypes) are really designed for backwards compatibility. If you’re going to go the standards-compliant route, you might as well go whole hog. (And, until Microsoft supports HTML 5, it’s not a meaningful option for real development.)

Even though standards will change, the techniques you learn with XHTML Strict will serve you well as you move to other standards.

The doctype for the upcoming HTML 5 standard is a lot easier than this XHTML nonsense. HTML 5 replaces this complicated doctype with one that’s a lot easier to remember: . That’s it. I can’t wait . . . .


The xmlns attribute

The html tag looks a little different from the one in Chapter 1 of this minibook. It has the term xmlns after it, which stands for XML NameSpace. This acronym helps clarify the definitions of the tags in your document:

Truthfully, not all validators require this part, but it doesn’t hurt to add it.


The meta tag

The last tag is the funky meta tag, which has been part of HTML for a long time. They allow you to describe various characteristics of a Web page:

The particular form of the meta tag you see here defines the character set to use. The utf character set handles a number of Western languages well.

The truth is, if you start with this framework, you’ll have everything you need to make official XHTML pages that validate properly.


You validate me

All this doctype and xmlns nonsense is worth it because of a nifty program — a validator. The most important validator is the W3C validator at http://validator.w3.org, as shown in Figure 2-1.

Figure 2-1: The W3C validator page isn’t exciting, but it sure is useful.

A validator is actually the front end of a piece of software that checks pages for validity. It looks at your Web page’s doctype and sees if the page conforms to the rules of that doctype. If not, it tells you what might have gone wrong.

You can submit code to a validator in three ways:

♦ Validate by URL. This option is used when a page is hosted on a Web server. Files stored on local computers can’t be checked with this technique. Book VIII describes all you need to know about working with Web servers, including how to create your own.

♦ Validate by File Upload. This technique works fine with files you haven’t posted to a Web server. It works great for pages you write on your computer but you haven’t made visible to the world. This is the most common type of validation for beginners.

♦ Validate by Direct Input. The validator page has a text box you can simply paste your code into. It works, but I usually prefer to use the other methods because they’re easier.

Validation might sound like a big hassle, but it’s really a wonderful tool because sloppy

Return Main Page Previous Page Next Page

®Online Book Reader