| XHTML
1. What is XHTML?
XHTML is the next generation
of HTML. It will take some time before browsers
and other software products are ready for
it. In the meantime there are some important
things you can do to prepare yourself for
it. XHTML is not very different from HTML
4.01, so bringing your code up to 4.01 standards
is a very good start. In addition, you should
start NOW to write your HTML code in lowercase
letters, and NEVER make the bad habit of
skipping end tags like the </p>.
The Most Important Differences
from HTML:
· XHTML elements must be properly nested
· XHTML documents must be well-formed
· Tag names must be in lowercase
· All XHTML elements must be closed
2. HTML & XHTML
Differences
The Most Important Differences from HTML:
XHTML elements must be properly nested
XHTML documents must be well-formed
Tag names must be in lowercase
All XHTML elements/tags must be closed
XHTML is a stricter, tidier version of HTML.
Pages written in XHTML work well in most browsers.
XHTML is the reformulation of HTML 4.0 as an application of XML.
The elements (tags) and attributes are almost identical to HTML.
How do HTML documents
become XHTML?
An XHTML document must:
- validate against one
of the three DTDs.
- start with the root
element <html>.
- refer to the XHTML
namespace http://www.w3.org/1999/xhtml
in its root element.
- contain one of the
following DOCTYPE declaration prior to
the root element:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "DTD/xhtml1-frameset.dtd">
|
How is XHTML better
than HTML? Back
to top
Extensibility: Under HTML,
an SGML (Standard Generalized Markup
Language) application, the addition
of a new group of elements requires
alteration of the entire DTD (language
specification). XML is a simplified
subset of SGML. This greatly eases
the development and integration
of new collections of elements.
Portability: By the year
2002 as much as 75% of Internet access could
be carried out on non-PC platforms such as
palm computers, televisions, fridges, automobiles,
telephones, etc. In most cases these devices
will not have the computing power of a desktop
computer, and will not be designed to accommodate
ill-formed HTML as do current browsers (bloated
with code to handle sloppy or proprietary
HTML).
Minimal HTML document:
<!DOCTYPE ...>
<html ... >
<head> ... </head>
<body> ... </body>
</html>
|
Minimal
XHTML document:
1: <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
2: <html xmlns="http://www.w3.org/1999/xhtml">
3: <head>
4: <title>Minimal document</title>
5: </head>
6: <body>
7: <p>
8: <a href="http://validator.w3.org/check/referer">validate</a>
9: </p>
10:</body>
11:</html>
|
The numbers and colons are not part of
the HTML file, but serve to associate the
following comments with the lines above: Back
to top
- Specifies the document
type.
- Declares this to be
an HTML document and declares an XML namespace.
- The head contains
items that are about the document.
- The title used in
the browser title bar, hotlists, listings,
etc.
- Closes the head.
- Body contains the
document's displayable content.
- Begins a paragraph.
- An anchor, to the
W3C validator.
- Closes the paragraph.
- Closes the body.
- Closes the html.
Definitions:
NAMESPACE
All elements in XHTML have names.
Together these elements belong to the XHTML
namespace for this document. You must declare
a namespace for the document to function.
Attribute
An attribute is a parameter to an element declared in the DTD. An attribute's
type and value range, including a possible default value, are defined
in the DTD.
DTD
A DTD, or document type definition, is a collection of XML declarations
that, as a collection, defines the legal structure, elements, and attributes
that are available for use in a document that complies to the DTD.
Document
A document is a stream of data that, after being combined with any other
streams it references, is structured such that it holds information contained
within elements that are organized as defined in the associated DTD.
See Document Conformance for more information.
Element
An element is a document structuring unit declared in the DTD. The element's
content model is defined in the DTD, and additional semantics may be
defined in the prose description of the element.
SGML
Standard Generalized Markup Language. Allows you to set up hierarchical
models for each type of document you produce. SGML forces each element
in the structure, which is labeled with descriptive markup such as "chapter," "title" and "paragraph," to
fit in the logical, predictable structure of your document.
Markup
Markup is everything in a document that is not content. Markup originally
referred to the handwritten notations that a designer would add to typewritten
text; these notations contained instructions to a typesetter about how
to lay out the copy and what typeface to use.
More
information on differences between HTML
and XHTML. Back
to top
3. Using XHTML
Using XHTML:
XHTML 1.0 is the first step toward a
modular and extensible web based on XML (Extensible
Markup Language). It provides the bridge
for web designers to enter the web of the
future, while still being able to maintain
compatibility with today's HTML 4 browsers.
It is the reformulation of HTML 4 as an application
of XML. It looks very much like HTML 4, with
a few notable exceptions, so if you're familiar
with HTML 4, XHTML will be easy to learn
and use. XHTML 1.0 was released on January
26th as a Recommendation by the W3C. Quick
template.
XHTML
1.0 Strict
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
Use this when
you want really clean markup, free
of presentational clutter. Use this
together with Cascading Style Sheets.
XHTML
1.0 Transitional
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
Use this when
you need to take advantage of HTML's
presentational features because many
of your readers don't have the latest
browsers that understand Cascading
Style Sheets.
XHTML
1.0 Frameset
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Frameset//EN"
"DTD/xhtml1-frameset.dtd">
Use this when
you want to use HTML Frames to partition
the browser window into two or more
frames.<
|
Practice
exercise #1
Practice
exercise #2
Back
to top
Copyright,2001
INT Media Group, Inc. All rights reserved.
Reprinted with permission from http://www.internet.com. |