• 1
  • 2
Home > Tips

What is XHTML? XHTML vs. HTML



  What is XHTML? What are the Differences between XHTML and HTML?

You may hear the XHTML many times but do you know exactly what XHTML is and the differences between XHTML and HTML?

In this article, Id like to share with you my opinions on what XHTML is and the differences between XHTML and HTML.



 What is XHTML?

XHTML, short for Extensible Hypertext Markup Language, is not too much different from HTML but there are some small but important differences between XHTML and HTML.

Saying simply, XHTML is a combination of XML and HTML, it has both the features of XML and HTML. In late 2000, World Wide Web Consortium (W3C) released XHTML 1.0. XHTML 1.0 is a new and enhanced language based on HTML, its expansibility and flexibility will meet more requirements of future network. After knowing the basic brief introduction of XHTML, many people may ask do we still need HTML? The answer is positive, we still need HTML because a great number of people have been used to using HTML as their design language and there are hundreds of millions web pages that use HTML.



 XHTML vs. HTML - The Differences between XHTML and HTML

 The first difference: XHTML files or documents must be well-formed:

What does it means by saying XHTML files or documents must be well-formed? In essence this means that all elements must have closing tags and that all the elements must nest properly.

For example

1. The elements that are nest properly:

<p>I am the <em>example</em>.</p>

2. The elements that are not nest properly:

<p>I am the <em>example </p></em>


 The second difference: The names of element and attribute must be in lower case:

For example, we cannot use <P></P> because they are uppercase, therefore, we must use <p></p> instead.


 The third difference: we must remember to close the tags.

For example, we cannot write codes like this: <p>I am a paragraph <p>I am a paragraph

The right way should be: <p> I am a paragraph</p> <p>I am a paragraph </p>


 The fourth difference: attribute values must always be quoted:

For example, attributes values that are not quoted: <td rowspan=3>. This is wrong for XHTML. The right way should be: <td rowspan='3'>


 The fifth difference: XHTML doesnt allow attribute minimization

For example: the below is the wrong way to write XHTML codes:

<input checked>
<input readonly>
<input disabled>

<option selected>

The right way should be:

<input checked=''>
<input readonly='readonly'>
<input disabled='disabled'>

<option selected='selected'>


 The sixth difference: Is Mandatory

You may find that we can create a HTML page without the DOCTYPE declaration. However, the DOCTYPE declaration is necessary for XHTML.

The example below shows an XHTML document with a minimum of required tags:

<!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>What is XHTML, Differences between XHTML and HTML</title>
</head>

<body>
......
</body>

</html>


Choose a SliceMaker Product to Create a Website on Your Own-30 Day Freetrial
SliceMaker Standard V3.6 - Freeware
SliceMaker Standard V3.6 - Freeware
The anyone-can-master webpage making software. You can create exceptional webpage/website on your own even if you're unfamiliar with webpage making.
$0
$0
SliceMaker Platinum V3.6 - Freeware
SliceMaker Platinum V3.6 - Freeware
The bestselling webpage making software, helps you create exceptional webpage/website without writing complicated CSS and DIV codes.
$0
$0
SliceMaker Deluxe V3.6 - Freeware
SliceMaker Deluxe V3.6 - Freeware
The all-in-one webpage making software, helps you create webpage/website of any style. It's the idea tool to create webpage/website.
$0
$0