Category(s)
Topic(s)
XHTML stands for Extensible Hyper Text Markup Language.
XHTML is a stricter, more XML-based version of HTML and it is supported by all major browsers.
XML is a markup language that requires all documents to be correctly marked up.
XHTML was created to enhance HTML's extensibility and flexibility to interact with other data formats, such as XML.
Unlike HTML, where browsers often ignore errors and attempt to display the website even with markup errors, XHTML enforces stricter error handling.
XHTML Differences from HTML
<!DOCTYPE>
is mandatory
<!DOCTYPE html>
The xmlns attribute in <html>
is mandatory
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
, <head>
, <title>
, and <body>
are mandatory
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Page Title</title>
</head>
<body>
<p>This is body</p>
</body>
</html>
Elements must always be properly nested
<!-- Correct -->
<p>This is a <strong><i>paragraph.</i></strong></p>
<!-- Incorrect -->
<p>This is a <strong><i>paragraph.</strong></i></p>
Elements must always be closed
<!-- Correct -->
<p>This is a paragraph.</p>
<hr/>
<!-- Incorrect -->
<p>This is a paragraph.
<hr>
Elements must always be in lowercase
<!-- Correct -->
<body>
<p>This is a paragraph</p>
</body>
<!-- Incorrect -->
<BODY>
<P>This is a paragraph</P>
</BODY>
Attribute names must always be in lowercase
<!-- Correct -->
<p class="para">This is a paragraph</p>
<!-- Incorrect -->
<p CLASS="para">This is a paragraph</p>
Attribute values must always be quoted
<!-- Correct -->
<p class="para">This is a paragraph</p>
<!-- Incorrect -->
<p class=para>This is a paragraph</p>
Attributes should be fully defined
<!-- Correct -->
<input type="text" name="name" disabled="disabled" />
<input type="checkbox" name="terms" value="I accept" checked="checked" />
<!-- Incorrect -->
<input type="text" name="name" disabled />
<input type="checkbox" name="terms" value="I accept" />
Please check below options for the links to our previous or next tutorial.