What Is HTML Versus XHTML

XHTML is a stricter, more XML-based rendition of HTML.

What is XHTML?

XHTML represents EXtensible HyperText Markup Language

XHTML is a stricter, more XML-based rendition of HTML

XHTML is HTML characterized as a XML application

XHTML is upheld by all significant programs

Why XHTML?

XML is a markup language where all archives should be increased effectively (be “all around shaped”).

XHTML was created to make HTML more extensible and adaptable to work with different information designs (like XML). What’s more, programs disregard mistakes in HTML pages, and attempt to show the site regardless of whether it has a few blunders in the markup. So XHTML accompanies a lot stricter mistake taking care of.

Assuming you need to examine XML

if it’s not too much trouble, please read our XML Tutorial.

The Most Important Differences from XHTML

  • <!DOCTYPE> is mandatory
  • The xmlns attribute in <html> is mandatory
  • <html>, <head>, <title>, and <body> are mandatory
  • Elements must always be properly nested
  • Elements must always be closed
  • Elements must always be in lowercase
  • Attribute names must always be in lowercase
  • Attribute values must always be quoted
  • Attribute minimization is forbidden

XHTML – <!DOCTYPE ….> Is Mandatory

An XHTML document must have an XHTML <!DOCTYPE> declaration.

The <html>, <head>, <title>, and <body> elements must also be present, and the xmlns attribute in <html> must specify the xml namespace for the document.

Example

Here is an XHTML document with a minimum of required tags: <!DOCTYPE html PUBLIC “-//e.g//DTD XHTML 1.1//EN”
“http://www.e.g.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html xmlns=”http://www.e.g.org/1999/xhtml”>
<head>
  <title>Title of document</title>
</head>
<body>

some content here…

</body>
</html>

XHTML Elements Must be Properly Nested

In XHTML, components should consistently be appropriately settled inside one another, similar to this:

Correct:

<b><i>Some text</i></b>

Wrong:

<b><i>Some text</b></i>

XHTML Elements Must Always be Closed

In XHTML, components should consistently be shut, this way:

Correct:

<p>This is a paragraph</p>
<p>This is another paragraph</p>

Wrong:

<p>This is a paragraph
<p>This is another paragraph

XHTML Empty Elements Must Always be Closed

In XHTML, void components should consistently be shut, this way:

Correct:

A break: <br />
A horizontal rule: <hr />
An image: <img src=”happy.gif” alt=”Happy face” />

Wrong:

A break: <br>
A horizontal rule: <hr>
An image: <img src=”happy.gif” alt=”Happy face”>

XHTML Elements Must be in Lowercase

In XHTML, component names should consistently be in lowercase, similar to this:

Correct:

<body>
<p>This is a paragraph</p>
</body>

Wrong:

<BODY>
<P>This is a paragraph</P>
</BODY>

XHTML Attribute Names Must be in Lowercase

In XHTML, property names should consistently be in lowercase, similar to this:

Correct:

<a href=”https://www.Examples.com/html/”>Visit our HTML tutorial</a>

Wrong:

<a HREF=”https://www.Examples.com/html/”>Visit our HTML tutorial</a>

XHTML Attribute Values Must be Quoted

In XHTML, property estimations should consistently be cited, this way:

Correct:

<a href=”https://www.Examples.com/html/”>Visit our HTML tutorial</a>

Wrong:

<a href=https://www.Examples.com/html/>Visit our HTML tutorial</a>

XHTML Attribute Minimization is Forbidden

In XHTML, characteristic minimization is taboo:

Correct:

<input type=”checkbox” name=”vehicle” value=”car” checked=”checked” />
<input type=”text” name=”lastname” disabled=”disabled” />

Wrong:

<input type=”checkbox” name=”vehicle” value=”car” checked />
<input type=”text” name=”lastname” disabled />