The Prolog: XML Tags |
Purpose
of the Prolog
|

The Prolog has three purposes:
- To declare which version of XML is used in this document;
- To define which character encoding is used;
- To point to the Document Type Definition for the document.
|
|
XML Declaration
|
The XML Declaration is the first thing that should go in the Prolog,
and hence the first thing in the entire document. Here is what the XML
Core Working Group says about XML Declarations:
[Definition:
XML documents should begin with an XML declaration which specifies the
version of XML being used.]
Let's look at a typical XML declaration:
<?xml version="1.0" encoding="iso-8859-1"?>
- <?
- No question about it ;-) this is the delimiter marking the beginning
of an XML tag
- xml version="1.0"
- is the string that identifies this file's code and its version. Version
1.0 was released in October 2000, and W3C's XML Working Group announces
new versions.
- encoding="iso-8859-1"
- tells what character-set this document uses. While this example uses
iso-8859-1,
the default is UTF-8.
(See module W22f
for more information about character sets.)
- ?>
- The closing delimiter that marks the end of an XML tag.
|
|
Doctype
|
The XML Core Working Group also requires a Document Type Declaration
(DTD), which should be the second thing in the document. The DTD
contains a machine-readable description of every element in that type
of document (in this case, XHTML) and the syntax or grammar
for building them into a document.
[Definition:
The XML document type declaration contains or points to markup
declarations that provide a grammar for a class of documents. This
grammar is known as a document type definition, or DTD. The document
type declaration can point to an external subset (a special kind of
external entity)
containing markup declarations, or can contain the markup declarations
directly in an internal subset, or can do both. The DTD for a document
consists of both subsets taken together.]
The document type declaration must appear before the first element in
the document.
Here's a typical XHTML document type declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Let's look at its pieces:
- <!
- This is the opening delimiter for XML documnent-type definition statements
- DOCTYPE
- Identifies the line as a document type declaration
- html
- This names the root element of the document - recall that
an XML document must have exactly one root element
- PUBLIC
- Available for general use; SYSTEM document type definitions are also
allowed
- "-//W3C//DTD XHTML 1.0 Transitional//EN"
- This is the complete definition of the document type, including:
- -//W3C
- Name of the developer or authority in charge of this type of document
- //DTD XHTML 1.0 Transitional
- Software-readable name of the specific document type, version, and
subtype. Transitional
is one of three XHTML 1.0 document types; the other two are Strict
and Frameset
- //EN
- The human-language name
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
- The URI of the formal, software-readable Document Type Definition.
- >
- Closing tag delimiter
|
HTML Tags |
|
HTML Entity
|
The HTML entity is the root of an XHTML document. This
is the object from which all the other entities are derived - the "parent"
of all the "child" entities.
Here's an XHTML root entity tag:
<html xmlns="http://www.w3.org/1999/xhtml">
made up of these pieces:
- <
- opening delimiter for all HTML tags
- html
- element name - this corresponds to the root element name
in the Doctype declaration
xmlns="http://www.w3.org/1999/xhtml"
- The XML namespace reference. In XML, a namespace is the vocabulary,
or list of words, the makes up the XML-derived language. Since anyone
can create an XML-based language (it's extensible!) there needs to be
a way for browsers to look up the vocabulary and the rules that go with
it. That's the purpose of this statement, and the location is give as
a standard Web URI.
- >
- The closing delimiter.
|
| Head
Entity |

The head and body entities are the two main parts
of every (X)HTML file, of course. The body contains everything
the browser is supposed to render for people to view - like the stage
on which a play is performed. The purpose of the head
is to provide a place for preparation - a backstage area, where
actors and support crew can get ready for the show. Since browsers are
ready to put on the display at a millisecond's notice, contents of the
head are all optional. They include:
- Title: what shows in the title bar of the display window.
Though not necessary, it really looks dumb not to have one!
- Stylesheets: CSS and other styles, when they are described
internally.
- Links: Usually used to link to external stylesheets.
- Script functions: program code for script language like JavaScript
and ASP. This is only necessary if a page has dynamic features, like
rollover buttons, hotspots with popups, or error-checking for forms.
- meta entities (generally known as "meta
tags"): used for several purposes described below.
|
|
Meta Tags
|
Why
meta tags?
According to Webster,
meta means "more comprehensive : transcending". Meta
tags are for information that is more comprehensive than other tags, transcending
the limits of the page itself.
Like everything else in the head entity, a meta tag is not
displayed in the browser window. Its purpose is to let coders do a wide
range of "behind the scenes" tasks, including:
- Listing the author's name or organization
<meta name="author" content="Sarah Strong"
/>
- Giving keywords to help search engines locate the file
<meta name="keywords" content="html xhtml prolog
head meta tag" />
- Providing a brief description for search engines to display
<meta name="description" content="Prolog and
Head Entities of an XHTML file" />
- Sending information to the browser, such as the character set in use
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
Meta tags are quite flexible, but they use a limited number of attributes:
| id |
An identifying name or number |
| http-equiv |
Information normally transmitted in the HTTP protocol |
| name |
Used to name the kind of information the tag contains |
| content |
The information we want the tag to contain |
| scheme |
If this tag is used to contain RDF
information, this attribute names the vocabulary source |
There are two main types of meta tags:
- those that convey information related to the HTTP transfer process,
and
- those with free-form information named in the tag.
We'll take a look at each of those types here... |
| http-equiv |
Meta tags that have information about the type of file or the transfer
process, use the attribute http-equiv. That's because the information
is the equivalent to what might be transmitted in the HTTP header sent
by the server to the browser.
Here are the major types of HTTP commands whose equivalents are useful
in meta tags:
|
| HTTP Command |
What It's For |
Examples |
| content-type |
Sending information to the browser
about what the contents of the file are.
This is useful for older browsers that didn't recognize the XML and
DOCTYPE tags. |
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8"> |
| refresh |
Causing the browser to load a page
after a given number of seconds.
This is useful if your page has moved to a new location, and you want
to automatically send the viewer to the new page.
The content can also have the time (in seconds) without a URL. In
this case, the browser requests the same page to be re-sent.
This is useful for pages with info that changes periodically, such
as weather observations or stock market quotes. |
<meta http-equiv="Refresh" content="10;
URL=http://www.wccnet.edu/finaid.html">
<meta http-equiv="Refresh" content="10"> |
|
| Name
Metatags |
Details soon... |
About This Document |
|
Click here for review questions
related to this module's objectives. |
|
Audience
|
This module is for people who know how to create valid, well-formed
XHTML code (see module X11c) and are ready to
learn about document prolog and head entities.
|
| Objectives |
On successful completion of this module, you will be able to:
- Discuss the purpose of the prolog and head portions of an XHTML
file.
- Define doctypes and identify their different uses
- Define the purpose of meta information in your XHTML document
- Declare an encoding type for your document
|
| Module X12c: XHTML Prolog and Head Entities |
This document is part of a modular
instruction series in Computer Instruction. For more information, see
the overview
or the list of modules in this series, W: World Wide
Web. This document has been used in the following classes: INP
150. |
| History |
Original: 3 October 2003, by
Laurence J. Krieg
Last modification:
Monday, 31-Aug-2009 11:48:07 EDT
|
| Copyright |
Copyright © 2003, Laurence
J. Krieg, Washtenaw Community College
Instructors: You may point to this file in your Web-based materials; however,
its location may change without notice.
Students: You are welcome to make a copy for your personal use.
All other uses: Please contact the author, Laurence
J. Krieg, for permission: krieg@ieee.org. |