Introduction to XHTML
XHTML stands for
”eXtensible Hyper Markup Language”. It is an extend version of HTML 4.01.
XHTML is a such HTML which is defined in XML format .Therefore, it is an XML
application. XHTML is basically supported by almost all the available major
browsers like Internet Explorer, Opera, Safari, and Chrome.
There are many web pages
available on the internet that contain “bad HTML” means those don't follow the
actual principle of HTML , but still execute very well.
For example
<html>
<head>
<title>
This is a bad HTML page
</title>
</head>
<body>
<h1>Bad HTML
<p> This is a web page that contain bad HTML.
</body>
</html>
In above example ,it
doesn't follow the rule of HTML (ie. Every tag is started with starting tag and
ended with ending tag ) as it doesn't contain ending tag, but above code will
work well ,if you run it in browser.
Therefore, XHTML was
developed by combining the strength(properties) of HTML and XML.
How to convert from HTML
to XHTML
-
< !DOCTYPE> is mandatory
in XHTML. So add an XHTML <! DOCTYPE>.
-
Add an xmlns attribute
to the html element of every page.
-
Change all element's
name in HTML page to lowercase format.
-
Change all empty
elements of HTML page in order to obtain XHTML page.
-
Change all attribute's
name in HTML page to lowercase and then quoted all attribute's values.
Hence, XHTML is differ from
HTML in Document structure, elements and attributes format.
* Document Structure
XHTML <! DOCTYPE> , XML
namespace attribute in <html> tag, <html>,<head>, <title> and <body> are
mandatory.
*XHTML Elements
->XHTML elements must be
properly nested.
-> XHTML elements must
always be closed.
->XHTML elements must in
lowercase.
->XHTML documents must have
one root element.
* XHTML attributes
->Attributes name must be in
lowercase.
->Attributes values must be
quoted.
->Attributes minimization is
not allowed.