Join Bill Weinman for an in-depth discussion in this video structure of an XHTML document, part of XHTML Essential Training.
This lesson will take a look at the structure of an XHTML document. In the overview lesson you learned a little bit about the structure of the XHTML document. In this lesson you'll learn some more details. Open your Examples folder to the Doctype folder and open the strict.html document. You won't often be using, at least in this course we won't be often using the strict version of the language, but it works for the purposes of this lesson. First of all you have the XHTML declaration. Technically it's not required under all circumstances. There's a statement in the XML specification that says an XML declaration is not required in all XML documents, however--there's always a however, isn't there-- however, XHTML documents' authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16, and no encoding was determined by a higher level protocol.
That's a lot of stuff. Let's take a brief look at the history of character encodings. Right up here there's a attribute, the XML declaration, that says encoding equals ISO 8859-1. ISO is the International Organization for Standards, and they have specified that standard 8859-1 is a character set which interestingly enough is a very, very close to the old ASCII character set. Back in the early days of computers when all computers just assumed that everybody spoke English, there was ASCII which stands for the American Standard Code for Information Interchange.
And it's a code to define 128 characters, most of them visible. Most of them right there on your keycaps if you're using an English language or American English keyboard. Most of those keys are right there on your keycaps from the ASCII character set. And that worked great until people in other countries wanted to use computers to type in other languages. Some of them don't even use any of the same characters as English. Some of them don't even go left to right or right to left. So it became necessary to specify a way of representing all of these different characters from all of these different languages.
And so the concept of various character sets and supporting various character sets with the same piece of code became popular. Enter ISO. The 8859 series of character sets mostly used the western characters that we find in English, French, German, you know, western type languages like that. They have the other series of character sets for different types of languages. ISO 8859 is the most common character set in the world. There's a whole other type of character set, a whole other body of character sets called UTF, which I believe stands for Universal Text Format. The UTF character sets-- there's 8-bit versions and 16-bit versions-- have a whole lot more characters in them, and for various reasons are preferred by the real propeller heads in the world.
Problem is that the rest of us don't all have computers that do UTF very well, and it's been my experience that when I encode Web pages with UTF, they just don't show up right on a lot of computers today. Maybe in the future that'll work, but for today, I always use and I recommend that you use the ISO 8859-1 if you're doing English language, or if you're not then use the character set that's most common in your country, in your region, in your language. That's specified right here. The fact that it's not UTF means that this whole line is required and even if it were UTF I would still recommend putting it there. It's just not a bad idea and it doesn't hurt anything, and it makes everything a lot more consistent.
This also specifies the version of XML that's being used and remember XHTML is an application of XML. And so this XML declaration is the part of the document that says, "This is XML and this document is using an application of XML," which in this case is XHTML and that part of it is specified here. Before we get to the rest of the document, let's take a look at the doctype. The doctype specifies which version of XHTML we're using. You'll notice that the doctype says HTML here, and it says XHTML there. What that means is that XHTML is really a version of HTML that's written in XML, and if that's not enough acronyms for you we got a lot more. This specifies which DTD, the Document Type Definition, is being used for this document, and there's three versions of the XHTML DTD. There is the strict version which this document is.
There is the transitional version which this document is. And then finally, whoops, there is the frameset version which this document is. We'll take a moment and look at each of them briefly. The strict version uses the strict version of the XHTML language, which is very much like the strict version of HTML 4. It is the version of the language that does not include any of the so-called depreciated elements which mostly have to do with things that you could handle better in a style sheet if you choose to use style sheets.
I use style sheets a lot. I'll also never use the strict version because I like for my documents to degrade gracefully to older browsers that don't understand style sheets. Just the way I am. You don't necessarily have to do it that way. I think it works for the broadest audience today. So that's the strict document. The transitional doctype is the one that we'll be using the most in this course. This one includes things like the font tag, and the background color, and things like that. This is the one that is the most HTML compatible to older versions of HTML and HTML browsers. It's meant to be used in that transitional period between the past and the future. And then finally the frameset doctype is used for frames documents. You remember frames.
Let's bring that up in the browser. This is a frames document and it's actually four documents. The outer document which defines the frames themselves is the one that uses the frameset DTD. That's this document here. This defines the frames and it references the documents that go inside each of the frames, which are these red, yellow, and blue documents. And those are these. Roses are red, my love is blue, quack! Each of those documents, the red, yellow, and blue documents, in turn, use the transitional.
See, there's the transitional. That's the yellow document. There's the red document, also transitional, and there's the blue document, also transitional. And those documents appear inside of the frames. (Typing.) And the definition of the structure of the frame document is in the frameset document, and that is this one here. And we'll cover frames in more detail in a later lesson, but there it is. And that uses them the document type frameset.
So there you have it, the three different doctypes: strict, transitional, and frameset. Most of the rest of this course will concentrate on the transitional doctype.