HTML and XHTML:

XHTML stands for Extensible Hypertext Markup Language. This means that the XHML is an extended version of HTML that is it contains more functions than the HTML. The XHTML is follows its rules strictly, for example, the tags or the element names should be written in lowercase letters instead of uppercase and this rule is strictly maintained in the XHTML. The XHTML is supported by the XML. The XHTML is a great revolution of the internet. XHTML is just like the HTML version 4 or HTML 4.0. There are minor differences between these two.


Why XHTML is used?

XHTML is language that is easier to maintain. XHTML is easy to learn and teach. XHTML documents are easy to upgrade to the new versions.


Rules for writing XHTML

XHTML follows strict rules that are stated below:

  1. All the attributes and elements and tags should be written in lowercase letters.
  2. The values that are assigned to attributes must be written within quotation marks.
  3. All the non empty elements or tags should be closed.
  4. All the empty elements should be terminated using a space and a slash.
  5. The elements must be nested properly.
  6. Do not minimize the attributes.
  7. The document type is mandatory to write.
  8. The xmlns attribute is necessary to write in the html tag, it will declare that the document is an XHTML document.
  9. The tags <html>, <head>, <title> and <body> should be used. They are mandatory.

Now let us explain all the points with examples:

EXAMPLES

  1. Attributes, elements, tags should be in lowercase like:

<html>, <title>, <head>, <body>

lowercase

  1. The values that are assigned to attributes must be written within quotation marks as follows:

<div style=”width: 100% ” >

quotation

  1. All the non empty elements or tags should be closed as follows:

<p> This is paragraph 1. This tag should be closed. </p>

p

  1. All the empty elements should be terminated using a space and a slash as shown below:

Line break element: <br />

br

  1. The elements must be nested properly like:

<p> <b> This is Boldface </b> </p>

boldface

  1. Do not minimize the attributes.

<input type = “text” name = “Last Name” checked = “checked” />

This should be written instead of the following:

<input type = “text” name = “Last Name” checked />

  1. The document type is mandatory to write. XHTML must have the DOCTYPE declaration as:

    doctype-declaration

  2. The xmlns attribute is necessary to write in the html tag, it will declare that the document is an XHTML document like:

    xhtml-document

  3. The tags <html>, <head>, <title> and <body> must be used. They are mandatory.

<html>

<head>

<title> Document title </title>

</head>

<body>

Content of the document

</body>

</html>

content-of-the-document