Home arrow HTML arrow Page 5 - XHTML Explained
HTML

XHTML Explained


I'm sure you've heard people mumbling about XHTML and how it combines HTML and XML to create the "next generation" of HTML. I too had heard the mumbling, but actually had no idea what XHTML was... up until about 2 months ago. In this article, Mitchell gives us a quick run down of what XHTML is, some of its benefits, how it can be used, and what it looks like. He wraps up the article with a couple of XHTML examples.

Author Info:
By: Mitchell Harper
Rating: 4 stars4 stars4 stars4 stars4 stars / 9
December 29, 2001
TABLE OF CONTENTS:
  1. · XHTML Explained
  2. · XHTML Defined
  3. · XHTML Benefits
  4. · DTD's
  5. · XHTML Examples
  6. · Conclusion

print this article
SEARCH DEVARTICLES

XHTML Explained - XHTML Examples
(Page 5 of 6 )

As you can probably guess by now, XHTML code looks very similar to plain old HTML code, with just a couple of syntactic differences. Three examples of valid XHTML documents are shown below. They were validated using the W3Cís XHTML validation tool, located at http://validator.w3.org/.

Example 1:

This example used the strict DTD, meaning that every single tag must be closed properly, all attributes assigned values, etc:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html

PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title> Strict DTD XHTML Example </title>

</head>

<body>

<p>

Please Choose a Day:

<br /><br />

<select name="day">

<option selected="selected">Monday</option>

<option>Tuesday</option>

<option>Wednesday</option>

</select>

</p>

</body>

</html>


Example 2:

This example uses the transitional DTD, which provides support for older browsers that donít recognize style sheets. You can see it uses several attributes within the <body> tag, which arenít allowed when using the strict DTD:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html

PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title> Transitional DTD XHTML Example </title>

</head>

<body bgcolor="#FFFFFF" link="#000000" text="red">

<p>This is a transitional XHTML example</p>

</body>

</html>


Example 3:

This example uses the frameset DTD, which allows us to split one XHTML page into multiple frames, with each frame containing an XHTML page within it:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html

PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"

"DTD/xhtml1-frameset.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title> Frameset DTD XHTML Example </title>

</head>

<frameset cols="100,*">

<frame src="toc.html" />

<frame src="intro.html" name="content" />

</frameset>

</html>

blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials