SlideShare a Scribd company logo
Fast and Easy XHTML - XHTML Tutorial, By Shirley E. Kaiser, M.A., SKDesigns - Website Tips at Websitetips.com




 December, 2001, Updated March 2006

 Copyright © 2001-2006, Shirley E. Kaiser, M.A., SKDesigns. All rights reserved.




 Wondering how to turn your HTML markup into XHTML? Here are a few quick tips to

 teach you the very basics, a sample XHTML document, and resources for more

 information.


 If you already know HTML, I suspect you can learn how to implement these markup

 changes within a couple of hours. If you just dig in and give it a try, I think you'll be

 pleasantly surprised to see that it's easier than you may have thought.


 Ready to give it a try? Let's go....



 The Basics
http://websitetips.com/articles/xhtml/basics/ (1 of 6)3/20/2006 11:32:47 AM
Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com




           1. All your markup needs to be in lowercase. For example, instead of <P></P>

                 it needs to be <p></p> for XHTML.

           2. Every tag must have a corresponding ending tag, such as <p></p> and

                 <li></li>. Some tags don't have a corresponding ending tag, such as <br>,

                 <hr>, and others. Those tags, to be backward compatible will look like this

                 instead:


                 <br />

                 <hr />


                 (Below is an XHTML document sample that shows more of these.)

           3. Every attribute value must be in double quotes, such as:

                 <img src="image.gif" height="150" width="40" alt="funny face" />


                 Notice that since the <img> tag doesn't have a corresponding ending tag that

                 it also is closed with the extra space and slash, too.

           4. Nesting must be correct (and symmetrical). HTML also requires correct

                 nesting, but it wasn't always as problematic in browsers. XHTML requires it

                 done properly, though. For example, this is incorrect:

                 <p><strong>Text</p></strong>


                 This is correct:

                 <p><strong>Text</strong></p>

           5. An ampersand (&) within an attribute value must use its character entity

                 reference. For example, a URL like this:


                 <a href="http://www.foo.com/cgi-bin/

http://websitetips.com/articles/xhtml/basics/ (2 of 6)3/20/2006 11:32:47 AM
Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com



                 class.pl?saturday&night&live">foo</a>


                 must instead be:


                 <a href="http://www.foo.com/cgi-bin/

                 class.pl?saturday&amp;night&amp;live">foo</a>

           6. Your markup must be well-formed. If you've already been writing good

                 markup that validates with W3C, it's no big deal. If not, it's a good time to

                 clean up your markup.



 A New DTD

 In addition to the above is a new DTD, too. The sample below is for XHTML 1.0

 transitional.




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

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

            "http://www.w3.org/TR/xhtml1/DTD/

            xhtml1-transitional.dtd">

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



 The first line, beginning with <?xml version= ..., is the xml prolog, and it's

 recommended but not required. Note that using the xml prolog will trigger IE6 Quirks

 Mode, so you might want to leave it out or learn more about it before deciding. The



http://websitetips.com/articles/xhtml/basics/ (3 of 6)3/20/2006 11:32:47 AM
Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com
 xml prolog tells the browser that your document is based upon a DTD using XML, and

 that it's using a standard character encoding.


 The second line, beginning with <!DOCTYPE ....>, will look more familiar to you, this

 time representing XHTML 1.0 transitional.


 Then, the last line beginning with <html xmlns=" ....> replaces the <html>

 element, telling the browser the language and the namespace.


 Below is a sample XHTML document. Note that all the markup is in lowercase, there

 are quotes around the attribute values, the new endings for the tags that don't have

 corresponding ending tags, and it is all well formed.



 A Sample XHTML Document


            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <title>Nifty New XHTML document</title>

            <meta name="description" content="This is the coolest XHTML document
            on the Internet." />

            <link rel="stylesheet" type="text/css" href="stylesheet.css" />

            </head>

            <body>

            <p>Content here.</p>
            <p>Content here.</p>



http://websitetips.com/articles/xhtml/basics/ (4 of 6)3/20/2006 11:32:47 AM
Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com

            <ol>
               <li>List item one</li>
               <li>List item two</li>
            </ol>


            <dl>
               <dt>Term</dt>
               <dd>definition</dd>
            </dl>


            <img src="image.gif" height="150" width="40" alt="funny face" />

            <br/>

            <table class="data">
            <tr><td>Green eggs</td><td>Ham</td></tr>
            </table>



            <form method="get" action="foo">

            <select name="">
            <option value="all">All Products</option>
            <option value="books">Books</option>
            </select>

            <input type="text" name="keyword" size="10"
            value="" />

            <input type="submit" name="Search" value="Go!" />

            </form>


            </body>
            </html>




 Resources




http://websitetips.com/articles/xhtml/basics/ (5 of 6)3/20/2006 11:32:47 AM
Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com




                                        To learn lots more about XHTML, check out WebsiteTips.com's
 XHTML section for annotated links to W3C recommendations, articles and tips, sites

 devoted to XHTML, and more.


 Also highly recommended is Molly Holzschlag's book, XML, HTML, XHTML Magic

 published by New Riders.



         This tutorial was originally published December 09, 2001 at Brainstorms and Raves.



         Copyright © 2001 Shirley E. Kaiser, M.A. All Rights Reserved. Reprint with permission only.

         Please contact the author for details.




                                               Today is March 20, 2006 - PST
                                Copyright © 1996-2006 WebsiteTips.com. All rights reserved.
                                           Created and maintained by SKDesigns.


                                      http://websitetips.com/articles/xhtml/basics/
                                      Last modified March 20, 2006 - 7:16pm PST




http://websitetips.com/articles/xhtml/basics/ (6 of 6)3/20/2006 11:32:47 AM

More Related Content

PDF
xhtml-documentation
PDF
Introduction to XHTML
PPTX
Html vs xhtml
PDF
Web I - 02 - XHTML Introduction
DOCX
What is html xml and xhtml
PPTX
Lecture 4 - Adding XTHML for the Web
PPT
Intr to-html-xhtml-1233508169541646-3
xhtml-documentation
Introduction to XHTML
Html vs xhtml
Web I - 02 - XHTML Introduction
What is html xml and xhtml
Lecture 4 - Adding XTHML for the Web
Intr to-html-xhtml-1233508169541646-3

What's hot (20)

KEY
HTML/CSS Lecture 1
PPS
PPT
PPTX
Dynamic HTML (DHTML)
PPTX
Css presentation lecture 1
PPTX
Web page concept final ppt
PPTX
Dhtml
PPTX
Unit ii java script and xhtml documents and dynamic documents with javascript
PPTX
The Difference between HTML, XHTML & HTML5 for Beginners
PPTX
Grade 10 COMPUTER
PPT
Design Tools Html Xhtml
PPTX
uptu web technology unit 2 html
PPT
Xhtml
PDF
Html beginner
PPSX
PPSX
HTML & XHTML Basics
PPT
Introduction to html5
PPTX
PDF
PDF
Html css workshop, lesson 0, how browsers work
HTML/CSS Lecture 1
Dynamic HTML (DHTML)
Css presentation lecture 1
Web page concept final ppt
Dhtml
Unit ii java script and xhtml documents and dynamic documents with javascript
The Difference between HTML, XHTML & HTML5 for Beginners
Grade 10 COMPUTER
Design Tools Html Xhtml
uptu web technology unit 2 html
Xhtml
Html beginner
HTML & XHTML Basics
Introduction to html5
Html css workshop, lesson 0, how browsers work
Ad

Similar to xhtml_basics (20)

PPTX
Introduction to whats new in css3
PDF
More On Html 5
PPT
Eye catching HTML BASICS tips: Learn easily
PDF
A Primer on HTML 5 - By Nick Armstrong
PPTX
Web technologies: Lesson 2
PDF
Html beginners tutorial
PPTX
Html Workshop
PPT
PDF
[In Control 2010] HTML5
PDF
WDIM268 Week 6 (Summer 2010)
PDF
2001: Bridging the Gap between RSS and Java Old School Style
PDF
HTML practical file
PDF
HTML Foundations, part 1
PDF
Sitepoint.com a basic-html5_template
PDF
Killing the Angle Bracket
PDF
Web Design Bootcamp - Day1
PPTX
Session ii(html)
PDF
GDI Seattle Intermediate HTML and CSS Class 1
PPTX
HTML (Basic to Advance)
Introduction to whats new in css3
More On Html 5
Eye catching HTML BASICS tips: Learn easily
A Primer on HTML 5 - By Nick Armstrong
Web technologies: Lesson 2
Html beginners tutorial
Html Workshop
[In Control 2010] HTML5
WDIM268 Week 6 (Summer 2010)
2001: Bridging the Gap between RSS and Java Old School Style
HTML practical file
HTML Foundations, part 1
Sitepoint.com a basic-html5_template
Killing the Angle Bracket
Web Design Bootcamp - Day1
Session ii(html)
GDI Seattle Intermediate HTML and CSS Class 1
HTML (Basic to Advance)
Ad

More from tutorialsruby (20)

PDF
&lt;img src="../i/r_14.png" />
PDF
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
PDF
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
PDF
&lt;img src="../i/r_14.png" />
PDF
&lt;img src="../i/r_14.png" />
PDF
Standardization and Knowledge Transfer – INS0
PDF
xhtml_basics
PDF
xhtml-documentation
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
HowTo_CSS
PDF
HowTo_CSS
PDF
BloggingWithStyle_2008
PDF
BloggingWithStyle_2008
PDF
cascadingstylesheets
PDF
cascadingstylesheets
PDF
Winter%200405%20-%20Advanced%20Javascript
PDF
Winter%200405%20-%20Advanced%20Javascript
&lt;img src="../i/r_14.png" />
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
Standardization and Knowledge Transfer – INS0
xhtml_basics
xhtml-documentation
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
HowTo_CSS
HowTo_CSS
BloggingWithStyle_2008
BloggingWithStyle_2008
cascadingstylesheets
cascadingstylesheets
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PPT
Teaching material agriculture food technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Tartificialntelligence_presentation.pptx
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Approach and Philosophy of On baking technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Advanced methodologies resolving dimensionality complications for autism neur...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Digital-Transformation-Roadmap-for-Companies.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
Teaching material agriculture food technology
Machine Learning_overview_presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Tartificialntelligence_presentation.pptx
gpt5_lecture_notes_comprehensive_20250812015547.pdf
A Presentation on Artificial Intelligence
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Unlocking AI with Model Context Protocol (MCP)
Assigned Numbers - 2025 - Bluetooth® Document
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Approach and Philosophy of On baking technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.

xhtml_basics

  • 1. Fast and Easy XHTML - XHTML Tutorial, By Shirley E. Kaiser, M.A., SKDesigns - Website Tips at Websitetips.com December, 2001, Updated March 2006 Copyright © 2001-2006, Shirley E. Kaiser, M.A., SKDesigns. All rights reserved. Wondering how to turn your HTML markup into XHTML? Here are a few quick tips to teach you the very basics, a sample XHTML document, and resources for more information. If you already know HTML, I suspect you can learn how to implement these markup changes within a couple of hours. If you just dig in and give it a try, I think you'll be pleasantly surprised to see that it's easier than you may have thought. Ready to give it a try? Let's go.... The Basics http://websitetips.com/articles/xhtml/basics/ (1 of 6)3/20/2006 11:32:47 AM
  • 2. Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com 1. All your markup needs to be in lowercase. For example, instead of <P></P> it needs to be <p></p> for XHTML. 2. Every tag must have a corresponding ending tag, such as <p></p> and <li></li>. Some tags don't have a corresponding ending tag, such as <br>, <hr>, and others. Those tags, to be backward compatible will look like this instead: <br /> <hr /> (Below is an XHTML document sample that shows more of these.) 3. Every attribute value must be in double quotes, such as: <img src="image.gif" height="150" width="40" alt="funny face" /> Notice that since the <img> tag doesn't have a corresponding ending tag that it also is closed with the extra space and slash, too. 4. Nesting must be correct (and symmetrical). HTML also requires correct nesting, but it wasn't always as problematic in browsers. XHTML requires it done properly, though. For example, this is incorrect: <p><strong>Text</p></strong> This is correct: <p><strong>Text</strong></p> 5. An ampersand (&) within an attribute value must use its character entity reference. For example, a URL like this: <a href="http://www.foo.com/cgi-bin/ http://websitetips.com/articles/xhtml/basics/ (2 of 6)3/20/2006 11:32:47 AM
  • 3. Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com class.pl?saturday&night&live">foo</a> must instead be: <a href="http://www.foo.com/cgi-bin/ class.pl?saturday&amp;night&amp;live">foo</a> 6. Your markup must be well-formed. If you've already been writing good markup that validates with W3C, it's no big deal. If not, it's a good time to clean up your markup. A New DTD In addition to the above is a new DTD, too. The sample below is for XHTML 1.0 transitional. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> The first line, beginning with <?xml version= ..., is the xml prolog, and it's recommended but not required. Note that using the xml prolog will trigger IE6 Quirks Mode, so you might want to leave it out or learn more about it before deciding. The http://websitetips.com/articles/xhtml/basics/ (3 of 6)3/20/2006 11:32:47 AM
  • 4. Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com xml prolog tells the browser that your document is based upon a DTD using XML, and that it's using a standard character encoding. The second line, beginning with <!DOCTYPE ....>, will look more familiar to you, this time representing XHTML 1.0 transitional. Then, the last line beginning with <html xmlns=" ....> replaces the <html> element, telling the browser the language and the namespace. Below is a sample XHTML document. Note that all the markup is in lowercase, there are quotes around the attribute values, the new endings for the tags that don't have corresponding ending tags, and it is all well formed. A Sample XHTML Document <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Nifty New XHTML document</title> <meta name="description" content="This is the coolest XHTML document on the Internet." /> <link rel="stylesheet" type="text/css" href="stylesheet.css" /> </head> <body> <p>Content here.</p> <p>Content here.</p> http://websitetips.com/articles/xhtml/basics/ (4 of 6)3/20/2006 11:32:47 AM
  • 5. Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com <ol> <li>List item one</li> <li>List item two</li> </ol> <dl> <dt>Term</dt> <dd>definition</dd> </dl> <img src="image.gif" height="150" width="40" alt="funny face" /> <br/> <table class="data"> <tr><td>Green eggs</td><td>Ham</td></tr> </table> <form method="get" action="foo"> <select name=""> <option value="all">All Products</option> <option value="books">Books</option> </select> <input type="text" name="keyword" size="10" value="" /> <input type="submit" name="Search" value="Go!" /> </form> </body> </html> Resources http://websitetips.com/articles/xhtml/basics/ (5 of 6)3/20/2006 11:32:47 AM
  • 6. Fast and Easy XHTML, XHTML Tutorial, HTML, Web Standards, by Shirley ...ML Tutorials, CSS Tutorials and Tips, Website Tips at Websitetips.com To learn lots more about XHTML, check out WebsiteTips.com's XHTML section for annotated links to W3C recommendations, articles and tips, sites devoted to XHTML, and more. Also highly recommended is Molly Holzschlag's book, XML, HTML, XHTML Magic published by New Riders. This tutorial was originally published December 09, 2001 at Brainstorms and Raves. Copyright © 2001 Shirley E. Kaiser, M.A. All Rights Reserved. Reprint with permission only. Please contact the author for details. Today is March 20, 2006 - PST Copyright © 1996-2006 WebsiteTips.com. All rights reserved. Created and maintained by SKDesigns. http://websitetips.com/articles/xhtml/basics/ Last modified March 20, 2006 - 7:16pm PST http://websitetips.com/articles/xhtml/basics/ (6 of 6)3/20/2006 11:32:47 AM