SlideShare a Scribd company logo
1 of 21
HTML VS XHTML
24-09-2018
1
• Yastee A. Shah
By:
• Web Technology
Subject:
2
WHAT ARE MARKUP LANGUAGES?
• Markup languages are the foundation of the web-where it all started, when websites
were just static pages with text and a little formatting.
• Essentially, everything you see on the web is a combination of markup (text),
cascading style sheets or CSS (design), and front-end scripts (interactivity). That
markup, made possible by HTML, is what creates a site’s foundation.
24-09-2018
3
*https://html.com/
HTML
• HTML was the first Internet-based language developed strictly for the web.
Anything displayed in a browser is organized via HTML.
• Structure
24-09-2018
4
XHTML (eXtensible Hypertext Markup
Language)
• XHTML is essentially identical to HTML4 (the fourth iteration of HTML), but with
elements of XML that extend HTML’s capabilities.
24-09-2018
5
*https://developer.mozilla.org/en-US/docs/Learn/HTML
In summary…
• HTML came along first, XHTML was designed to fix problems with HTML.
• They’re all mark up languages that provide structure and organization to the
content of webpages and applications, but their relevance has shifted as newer
versions of HTML have evolved, rising to the challenges of mobile demands,
responsive design, and developers who want to accomplish more with less.
24-09-2018
6
The Most Important Differences from HTML:
Document Structure
• XHTML DOCTYPE is mandatory
• The xmls attribute in <html> is mandatory
• <html>, <head>, <title>, and <body>
are mandatory <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Title of document</title> </head>
<body>
some content
</body>
</html>
24-09-2018
7
XHTML Elements
• XHTML elements must be properly nested.
• XHTML elements must be always be closed
• XHTML elements must be in lowercase
• XHTML documents must have one root element
<html>
<head>
<title>This is bad HTML</title>
<body>
<h1>Bad HTML
<p>This is a paragraph
</body>
24-09-2018
8
XHTML Elements Must Always Be
Closed
This is wrong:
<p>This is a paragraph
<p>This is another paragraph
This is correct:
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Empty Elements Must Also Be Closed
This is wrong:
A break: <br>
A horizontal rule: <hr>
An image: <img src="happy.gif" alt="Happy face">
This is correct:
A break: <br />
A horizontal rule: <hr />
An image: <img src="happy.gif" alt="Happy face" />
24-09-2018
9
XHTML Attributes
• Attribute names must be in lower case
• Attribute values must be quoted
• Attribute minimization is forbidden
24-09-2018
10
*http://www.htmldog.com/guides/
XHTML Attribute Names Must Be In Lower Case
This is wrong:
<table WIDTH="100%">
Attribute Values Must Be Quoted
This is wrong:
<table width=100%>
XHTML Elements Must Be In Lower Case
This is wrong:
<BODY>
<P>This is a paragraph</P>
</BODY>
This is correct:
<table width="100%">
This is correct:
<table width="100%">
This is correct:
<body>
<p>This is a paragraph</p>
</body>
24-09-2018
11
• Attribute Minimization Is Forbidden
Wrong:
<input type="checkbox" name="vehicle" value="car" checked />
Correct:
<input type="checkbox" name="vehicle" value="car" checked="checked"/>
Wrong:
<input type="text" name="lastname" disabled />
Correct:
<input type="text" name="lastname" disabled="disabled" />
24-09-2018
12
HTML vs. XHTML
24-09-2018
13
*https://www.edx.org/course/introduction-to-html-and-
javascript
HTML XHTML
Introduction Main markup language for creating web
pages and other information that can be
displayed in a web browser.
Family of XML markup languages that
extend versions of HTML.
Filename extension .html, .htm .xhtml, .xht, .xml, .html, .htm
Internet media type text/html application/xhtml+xml
Type of format Document file format Markup language
Stands for HyperText Markup Language Extensible HyperText Markup Language
14
HTML XHTML
Application Application of Standard Generalized Markup Language
(SGML).
Application ofXML
Function
Web pages are written in HTML. Extended version of HTML that is stricter
and XML-based.
Nature
Flexible framework requiring purely HTML specific.
Restrictive subset of XML and needs to be
parsed with standard XML parsers.
Origin Proposed byTim Berners-Lee in 1987. WorldWideWeb Consortium
Recommendation in 2000.
Versions HTML 2, HTML 3.2, HTML 4.0, HTML 5. XHTML 1, XHTML 1.1, XHTML 2, XHTML 5.15
Features of HTML vs XHTML documents
• HTML documents are composed of elements that have three components-
1. start tag
2.end tag; element attributes given within tags and actual, textual and graphic
content
3.including tags. (Tag is a keyword which is enclosed within angle brackets).
• XHTML documents has only one root element.
• All elements including variables must be in lower case, and values assigned
must be surrounded by quotes, closed and nested for being recognized.
24-09-2018
16
*https://www.codecademy.com/learn/learn-html
• The declaration of DOCTYPE would determine rules for documents to follow.
• The underlying syntax of HTML allows many shortcuts that XHTML does not, such as
elements with optional opening or closing tags, and even EMPTY elements which must
not have an end tag.
• XHTML requires all elements to have an opening tag or a closing tag. XHTML, however,
also introduces a new shortcut: an XHTML
• Tag may be opened and closed within the same tag, by including a slash before the end
of the tag like this: <br/>. A fix for this is to include a space before closing the tag, as
such: <br />.
24-09-2018
17
How to Convert from HTML to XHTML
• Add an XHTML <!DOCTYPE> to the first line of every page
• Add an xmlns attribute to the html element of every page
• Include xml:lang and lang attributes on elements assigning language.
• Change all element and attribute names to lowercase
• Close all empty elements
• Include close tags for elements that can have content but are empty: <html></html>
• Include an extra space in empty-element tags: <html />
• Quote all attribute values
• Do not include XML declaration.
24-09-2018
18
24-09-2018
19
It is actually pretty easy. You just have to:
•Change your DOCTYPE
•Change Some Meta Tags
•Close all your tags properly
•Surround inline tags with block tags
•Eliminate the use of a few tags
•Leave the styling to Cascading Style Sheets
How to migrate from XHTML to HTML
• The language for an element should be specified with a lang attribute rather than the
XHTML xml:lang attribute.
• Remove the XML namespace (xmlns=URI). HTML has no facilities for namespaces.
• Change the document type declaration from XHTML to HTML.
• If present, remove the XML declaration. (Typically this is: <?xml version="1.0"?>).
• Change the XML empty-element syntax to an HTML style empty element (<br/> to
<br>).
24-09-2018
20
21
24-09-2018

More Related Content

What's hot

What's hot (20)

Basic HTML
Basic HTMLBasic HTML
Basic HTML
 
Html5 and-css3-overview
Html5 and-css3-overviewHtml5 and-css3-overview
Html5 and-css3-overview
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
Css Display Property
Css Display PropertyCss Display Property
Css Display Property
 
Html coding
Html codingHtml coding
Html coding
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
Html
HtmlHtml
Html
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
Html 5
Html 5Html 5
Html 5
 
BasicHTML
BasicHTMLBasicHTML
BasicHTML
 
HTML-(workshop)7557.pptx
HTML-(workshop)7557.pptxHTML-(workshop)7557.pptx
HTML-(workshop)7557.pptx
 
Html ppt
Html pptHtml ppt
Html ppt
 
Basic html structure
Basic html structureBasic html structure
Basic html structure
 
Span and Div tags in HTML
Span and Div tags in HTMLSpan and Div tags in HTML
Span and Div tags in HTML
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
HTML5 & CSS3
HTML5 & CSS3 HTML5 & CSS3
HTML5 & CSS3
 
Cascading style sheet
Cascading style sheetCascading style sheet
Cascading style sheet
 
Html basics
Html basicsHtml basics
Html basics
 
Javascript
JavascriptJavascript
Javascript
 

Similar to Html vs xhtml

CSE-HTML-PPT.pptx
CSE-HTML-PPT.pptxCSE-HTML-PPT.pptx
CSE-HTML-PPT.pptx
Ambika S
 

Similar to Html vs xhtml (20)

WT Module-1.pdf
WT Module-1.pdfWT Module-1.pdf
WT Module-1.pdf
 
Html5
Html5 Html5
Html5
 
9781285852645_CH01 research and analysis of data.pptx
9781285852645_CH01 research and analysis of data.pptx9781285852645_CH01 research and analysis of data.pptx
9781285852645_CH01 research and analysis of data.pptx
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
4_Traditional html vs xhtml.ppt
4_Traditional html vs xhtml.ppt4_Traditional html vs xhtml.ppt
4_Traditional html vs xhtml.ppt
 
Introduction to html course digital markerters
Introduction to html course digital markertersIntroduction to html course digital markerters
Introduction to html course digital markerters
 
Web design - HTML (Hypertext Markup Language) introduction
Web design - HTML (Hypertext Markup Language) introductionWeb design - HTML (Hypertext Markup Language) introduction
Web design - HTML (Hypertext Markup Language) introduction
 
Introduction to HTML.pptx
Introduction to HTML.pptxIntroduction to HTML.pptx
Introduction to HTML.pptx
 
Summary of-xhtml-basics
Summary of-xhtml-basicsSummary of-xhtml-basics
Summary of-xhtml-basics
 
1. html introduction
1. html introduction1. html introduction
1. html introduction
 
Lecture 2 introduction to html basics
Lecture 2 introduction to html basicsLecture 2 introduction to html basics
Lecture 2 introduction to html basics
 
HTML & CSS.ppt
HTML & CSS.pptHTML & CSS.ppt
HTML & CSS.ppt
 
Html presentation
Html presentationHtml presentation
Html presentation
 
Html.pptx
Html.pptxHtml.pptx
Html.pptx
 
Html (hypertext markup language)
Html (hypertext markup language)Html (hypertext markup language)
Html (hypertext markup language)
 
Presentation html
Presentation   htmlPresentation   html
Presentation html
 
wt mod1.pdf
wt mod1.pdfwt mod1.pdf
wt mod1.pdf
 
www.webre24h.com - [O`reilly] html and xhtml. pocket reference, 4th ed. - [...
www.webre24h.com - [O`reilly]   html and xhtml. pocket reference, 4th ed. - [...www.webre24h.com - [O`reilly]   html and xhtml. pocket reference, 4th ed. - [...
www.webre24h.com - [O`reilly] html and xhtml. pocket reference, 4th ed. - [...
 
CSE-HTML-PPT.pptx
CSE-HTML-PPT.pptxCSE-HTML-PPT.pptx
CSE-HTML-PPT.pptx
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Web
 

More from Yastee Shah

More from Yastee Shah (11)

AWT.pptx
AWT.pptxAWT.pptx
AWT.pptx
 
jdbc vs hibernate.pptx
jdbc vs hibernate.pptxjdbc vs hibernate.pptx
jdbc vs hibernate.pptx
 
FIND MINIMUM TIME TO FINISH ALL JOBS WITH GIVEN CONSTRAINTS.pptx
FIND MINIMUM TIME TO FINISH ALL JOBS WITH GIVEN CONSTRAINTS.pptxFIND MINIMUM TIME TO FINISH ALL JOBS WITH GIVEN CONSTRAINTS.pptx
FIND MINIMUM TIME TO FINISH ALL JOBS WITH GIVEN CONSTRAINTS.pptx
 
Application of Queue.pptx
Application of Queue.pptxApplication of Queue.pptx
Application of Queue.pptx
 
Edison's work habits and thinking about failure.pptx
Edison's work habits and thinking about failure.pptxEdison's work habits and thinking about failure.pptx
Edison's work habits and thinking about failure.pptx
 
Smart grid.pptx
Smart grid.pptxSmart grid.pptx
Smart grid.pptx
 
Raid
RaidRaid
Raid
 
Water Level Indicator
Water Level IndicatorWater Level Indicator
Water Level Indicator
 
Types of virus and saviour
Types of virus and saviourTypes of virus and saviour
Types of virus and saviour
 
Output devices
Output devicesOutput devices
Output devices
 
Math
MathMath
Math
 

Recently uploaded

Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
home
 
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
amitlee9823
 
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
amitlee9823
 
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
nirzagarg
 
B. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdfB. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdf
University of Wisconsin-Milwaukee
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
amitlee9823
 
Peaches App development presentation deck
Peaches App development presentation deckPeaches App development presentation deck
Peaches App development presentation deck
tbatkhuu1
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard ...
Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard  ...Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard  ...
Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard ...
nirzagarg
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
Recommendable # 971589162217 # philippine Young Call Girls in Dubai By Marina...
 
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...Top Rated  Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
Top Rated Pune Call Girls Koregaon Park ⟟ 6297143586 ⟟ Call Me For Genuine S...
 
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Basapura ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
Pooja 9892124323, Call girls Services and Mumbai Escort Service Near Hotel Hy...
 
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdfChapter 19_DDA_TOD Policy_First Draft 2012.pdf
Chapter 19_DDA_TOD Policy_First Draft 2012.pdf
 
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
Jigani Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bangal...
 
call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
call girls in Kaushambi (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝...
 
SD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptxSD_The MATATAG Curriculum Training Design.pptx
SD_The MATATAG Curriculum Training Design.pptx
 
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
Nisha Yadav Escorts Service Ernakulam ❣️ 7014168258 ❣️ High Cost Unlimited Ha...
 
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...AMBER GRAIN EMBROIDERY | Growing folklore elements |  Root-based materials, w...
AMBER GRAIN EMBROIDERY | Growing folklore elements | Root-based materials, w...
 
B. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdfB. Smith. (Architectural Portfolio.).pdf
B. Smith. (Architectural Portfolio.).pdf
 
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
Escorts Service Nagavara ☎ 7737669865☎ Book Your One night Stand (Bangalore)
 
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Saswad ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
💫✅jodhpur 24×7 BEST GENUINE PERSON LOW PRICE CALL GIRL SERVICE FULL SATISFACT...
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 
Peaches App development presentation deck
Peaches App development presentation deckPeaches App development presentation deck
Peaches App development presentation deck
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard ...
Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard  ...Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard  ...
Anamika Escorts Service Darbhanga ❣️ 7014168258 ❣️ High Cost Unlimited Hard ...
 
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdfJordan_Amanda_DMBS202404_PB1_2024-04.pdf
Jordan_Amanda_DMBS202404_PB1_2024-04.pdf
 

Html vs xhtml

  • 1. HTML VS XHTML 24-09-2018 1 • Yastee A. Shah By: • Web Technology Subject:
  • 2. 2
  • 3. WHAT ARE MARKUP LANGUAGES? • Markup languages are the foundation of the web-where it all started, when websites were just static pages with text and a little formatting. • Essentially, everything you see on the web is a combination of markup (text), cascading style sheets or CSS (design), and front-end scripts (interactivity). That markup, made possible by HTML, is what creates a site’s foundation. 24-09-2018 3 *https://html.com/
  • 4. HTML • HTML was the first Internet-based language developed strictly for the web. Anything displayed in a browser is organized via HTML. • Structure 24-09-2018 4
  • 5. XHTML (eXtensible Hypertext Markup Language) • XHTML is essentially identical to HTML4 (the fourth iteration of HTML), but with elements of XML that extend HTML’s capabilities. 24-09-2018 5 *https://developer.mozilla.org/en-US/docs/Learn/HTML
  • 6. In summary… • HTML came along first, XHTML was designed to fix problems with HTML. • They’re all mark up languages that provide structure and organization to the content of webpages and applications, but their relevance has shifted as newer versions of HTML have evolved, rising to the challenges of mobile demands, responsive design, and developers who want to accomplish more with less. 24-09-2018 6
  • 7. The Most Important Differences from HTML: Document Structure • XHTML DOCTYPE is mandatory • The xmls attribute in <html> is mandatory • <html>, <head>, <title>, and <body> are mandatory <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Title of document</title> </head> <body> some content </body> </html> 24-09-2018 7
  • 8. XHTML Elements • XHTML elements must be properly nested. • XHTML elements must be always be closed • XHTML elements must be in lowercase • XHTML documents must have one root element <html> <head> <title>This is bad HTML</title> <body> <h1>Bad HTML <p>This is a paragraph </body> 24-09-2018 8
  • 9. XHTML Elements Must Always Be Closed This is wrong: <p>This is a paragraph <p>This is another paragraph This is correct: <p>This is a paragraph</p> <p>This is another paragraph</p> Empty Elements Must Also Be Closed This is wrong: A break: <br> A horizontal rule: <hr> An image: <img src="happy.gif" alt="Happy face"> This is correct: A break: <br /> A horizontal rule: <hr /> An image: <img src="happy.gif" alt="Happy face" /> 24-09-2018 9
  • 10. XHTML Attributes • Attribute names must be in lower case • Attribute values must be quoted • Attribute minimization is forbidden 24-09-2018 10 *http://www.htmldog.com/guides/
  • 11. XHTML Attribute Names Must Be In Lower Case This is wrong: <table WIDTH="100%"> Attribute Values Must Be Quoted This is wrong: <table width=100%> XHTML Elements Must Be In Lower Case This is wrong: <BODY> <P>This is a paragraph</P> </BODY> This is correct: <table width="100%"> This is correct: <table width="100%"> This is correct: <body> <p>This is a paragraph</p> </body> 24-09-2018 11
  • 12. • Attribute Minimization Is Forbidden Wrong: <input type="checkbox" name="vehicle" value="car" checked /> Correct: <input type="checkbox" name="vehicle" value="car" checked="checked"/> Wrong: <input type="text" name="lastname" disabled /> Correct: <input type="text" name="lastname" disabled="disabled" /> 24-09-2018 12
  • 14. HTML XHTML Introduction Main markup language for creating web pages and other information that can be displayed in a web browser. Family of XML markup languages that extend versions of HTML. Filename extension .html, .htm .xhtml, .xht, .xml, .html, .htm Internet media type text/html application/xhtml+xml Type of format Document file format Markup language Stands for HyperText Markup Language Extensible HyperText Markup Language 14
  • 15. HTML XHTML Application Application of Standard Generalized Markup Language (SGML). Application ofXML Function Web pages are written in HTML. Extended version of HTML that is stricter and XML-based. Nature Flexible framework requiring purely HTML specific. Restrictive subset of XML and needs to be parsed with standard XML parsers. Origin Proposed byTim Berners-Lee in 1987. WorldWideWeb Consortium Recommendation in 2000. Versions HTML 2, HTML 3.2, HTML 4.0, HTML 5. XHTML 1, XHTML 1.1, XHTML 2, XHTML 5.15
  • 16. Features of HTML vs XHTML documents • HTML documents are composed of elements that have three components- 1. start tag 2.end tag; element attributes given within tags and actual, textual and graphic content 3.including tags. (Tag is a keyword which is enclosed within angle brackets). • XHTML documents has only one root element. • All elements including variables must be in lower case, and values assigned must be surrounded by quotes, closed and nested for being recognized. 24-09-2018 16 *https://www.codecademy.com/learn/learn-html
  • 17. • The declaration of DOCTYPE would determine rules for documents to follow. • The underlying syntax of HTML allows many shortcuts that XHTML does not, such as elements with optional opening or closing tags, and even EMPTY elements which must not have an end tag. • XHTML requires all elements to have an opening tag or a closing tag. XHTML, however, also introduces a new shortcut: an XHTML • Tag may be opened and closed within the same tag, by including a slash before the end of the tag like this: <br/>. A fix for this is to include a space before closing the tag, as such: <br />. 24-09-2018 17
  • 18. How to Convert from HTML to XHTML • Add an XHTML <!DOCTYPE> to the first line of every page • Add an xmlns attribute to the html element of every page • Include xml:lang and lang attributes on elements assigning language. • Change all element and attribute names to lowercase • Close all empty elements • Include close tags for elements that can have content but are empty: <html></html> • Include an extra space in empty-element tags: <html /> • Quote all attribute values • Do not include XML declaration. 24-09-2018 18
  • 19. 24-09-2018 19 It is actually pretty easy. You just have to: •Change your DOCTYPE •Change Some Meta Tags •Close all your tags properly •Surround inline tags with block tags •Eliminate the use of a few tags •Leave the styling to Cascading Style Sheets
  • 20. How to migrate from XHTML to HTML • The language for an element should be specified with a lang attribute rather than the XHTML xml:lang attribute. • Remove the XML namespace (xmlns=URI). HTML has no facilities for namespaces. • Change the document type declaration from XHTML to HTML. • If present, remove the XML declaration. (Typically this is: <?xml version="1.0"?>). • Change the XML empty-element syntax to an HTML style empty element (<br/> to <br>). 24-09-2018 20