0% found this document useful (0 votes)
130 views

The Most Important Differences:: What Is XHTML?

XHTML is a stricter version of HTML that is defined as an XML language. It consists of all HTML elements combined with XML syntax rules, such as proper nesting, lowercase element names, and closed elements. XHTML documents must include a DOCTYPE declaration and specific required elements like html, head, title, and body. The W3C modularized XHTML into smaller sets of elements that can be used separately or combined with other XML standards.

Uploaded by

Pinky Prakash
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
130 views

The Most Important Differences:: What Is XHTML?

XHTML is a stricter version of HTML that is defined as an XML language. It consists of all HTML elements combined with XML syntax rules, such as proper nesting, lowercase element names, and closed elements. XHTML documents must include a DOCTYPE declaration and specific required elements like html, head, title, and body. The W3C modularized XHTML into smaller sets of elements that can be used separately or combined with other XML standards.

Uploaded by

Pinky Prakash
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

What Is XHTML?

• XHTML stands for EXtensible HyperText Markup Language


• XHTML is almost identical to HTML 4.01
• XHTML is a stricter and cleaner version of HTML
• XHTML is HTML defined as an XML application
• XHTML is a W3C Recommendation

XHTML - Why?
XHTML is a combination of HTML and XML (EXtensible Markup Language).
XHTML consists of all the elements in HTML 4.01, combined with the strict
syntax of XML.
The Most Important Differences:
• XHTML elements must be properly nested
• XHTML elements must always be closed
• XHTML elements must be in lowercase
• XHTML documents must have one root element
Some More XHTML Syntax Rules
• Attribute names must be in lower case
• Attribute values must be quoted
• Attribute minimization is forbidden
• The XHTML DTD defines mandatory elements
• Mandatory XHTML Elements
• All XHTML documents must have a DOCTYPE declaration. The html,
head, title, and body elements must be present.
<!DOCTYPE Doctype goes here>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title goes here</title>
</head>

<body>
</body>

</html>

• This is an XHTML document with a minimum of required tags:


• Note: The DOCTYPE declaration is not a part of the XHTML document
itself. It is not an XHTML element. You will learn more about the XHTML
DOCTYPE in the next chapter.
• Note: The xmlns attribute in <html>, specifies the xml namespace for a
document, and is required in XHTML documents. However, the HTML
validator at w3.org does not complain when the xmlns attribute is missing.
This is because the namespace "xmlns=http://www.w3.org/1999/xhtml" is
default, and will be added to the <html> tag even if you do not include it.

An XHTML Example
This is a simple (minimal) XHTML document:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<title>simple document</title>
</head>
<body>
<p>a simple paragraph</p>
</body>
</html>
The DOCTYPE declaration above defines the document type. The rest of the document looks
like HTML.

Document Type Definitions (DTD)


• A DTD specifies the syntax of a web page in SGML
• DTDs are used by SGML applications, such as HTML, to specify rules for documents of
a particular type, including a set of elements and entity declarations
• An XHTML DTD describes in precise, computer-readable language, the allowed syntax
of XHTML markup
There are three XHTML DTDs:
• STRICT
• TRANSITIONAL
• FRAMESET
XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Use the strict DOCTYPE when you want really clean markup, free of presentational clutter. Use
it together with CSS.
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Use the transitional DOCTYPE when you want to still use HTML's presentational features.
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

Use the frameset DOCTYPE when you want to use HTML frames.
A DOCTYPE Was Added
The following DOCTYPE was added to the first line of every page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Tip: Your pages must have a DOCTYPE declaration if you want them to validate as correct
XHTML.

Empty Tags: <hr> , <br> and <img>


Empty tags are not allowed in XHTML. The <hr> and <br> tags should be replaced with <hr />
and <br />.
A general "find-and-replace" function was executed to swap the tags.
We decided not to close the <img> tags with </img>, but with /> at the end of the tag. This was
done manually.
IMPORTANT Compatibility Note:
To make your XHTML compatible with today's browsers, you should add an extra space before
the "/" symbol.
Validate XHTML With A DTD
Before an XHTML file can be validated, a correct DTD must be added as the first line of the file.
The Strict DTD includes elements and attributes that have not been deprecated or do not appear
in framesets:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
The Transitional DTD includes everything in the strict DTD plus deprecated elements and
attributes:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
The Frameset DTD includes everything in the transitional DTD plus frames as well:
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"

Validate Your XHTML With The W3C Validator


Top of Form

Input a web address in the box below:


http://w w w .w 3schools.com/xhtml/default.asp

Bottom of Form

Why XHTML Modularization?


XHTML contains most of the functionality a web developer will need.
For some purposes XHTML is too large and complex, and for other purposes it's too simple.
By splitting XHTML into modules, the W3C (World Wide web Consortium) has created small
and well-defined sets of XHTML elements that can be used separately for small devices, or
combined with other XML standards in more complex applications.
With modular XHTML, designers can:
• Choose the elements to be supported by a device
• Simplify XHTML for small devices
• Extend XHTML for complex applications by adding new XML functionality (like
MathML, SVG, Voice and Multimedia)
• Define XHTML profiles like XHTML Basic (a subset of XHTML for mobile devices)

XHTML Modules
W3C has split the definition of XHTML into 28 modules:
Module name Description
Applet Module Defines the deprecated* applet element
Base Module Defines the base element
Basic Forms Module Defines the basic forms elements
Basic Tables Module Defines the basic table elements
Bi-directional Text Module Defines the bdo element
Client Image Map Module Defines browser side image map elements
Edit Module Defines the editing elements del and ins
Forms Module Defines all elements used in forms
Frames Module Defines the frameset elements
Hypertext Module Defines the a element
Iframe Module Defines the iframe element
Image Module Defines the img element
Intrinsic Events Module Defines event attributes like onblur and onchange
Legacy Module Defines deprecated* elements and attributes
Link Module Defines the link element
List Module Defines the list elements ol, li, ul, dd, dt, and dl
Metainformation Module Defines the meta element
Name Identification Module Defines the deprecated* name attribute
Object Module Defines the object and param elements
Presentation Module Defines presentation elements like b and i
Scripting Module Defines the script and noscript elements
Server Image Map Module Defines server side image map elements
Structure Module Defines the elements html, head, title and body
Style Attribute Module Defines the style attribute
Style Sheet Module Defines the style element
Tables Module Defines the elements used in tables
Target Module Defines the target attribute
Text Module Defines text container elements like p and h1
* Deprecated elements should not be used in XHTML.

You might also like