xhtml (extensible hypertext markup language ) is a family of xml markup language that mirror or extend versions of the widely used Hypertext markup language the language in which web pages are written.

xhtml file extension can be .xhtml , .html , .htm ,.xht

xhtml web page is same as html but some xml rules follows at time when we develop with xhtml.

xhtml document:-some point where xhtml differ from html.

  • the root element of an xhtml document must be html,and must contain an xmlns attribute to associate it with the xhtml namespace xml:lang attribute to identify the document with a natural language:
  • like as:< html xmlns="" xml:lang="en">
  • xhtml doctype is mandatory.
  • <html> ,<head>,<title>,<body>is mandatory.

xhtml attributes:-

  • xhtml attribute must be casesensitive.
  • xhtml attribute must be quoted.
  • xhtml attribute minimization is forbidden.

xhtml element:-

  • xhtml element must be casesensitive.
  • xhtml element must be lowercase
  • xhtml element must always be closed.
  • xhtml element must be properly nested.
  • xhtml element must have one root element.

xhtml <doctype>

when we develop a web page with xhtml language then we first add xhtml doctype at the top of web page. a web page html root element must contain an xmlns attribute to associate it with the XHTML namespace. <html>,<head>,<title>,<body> element must present in xhtml web page.

xhml web page code example

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          <html xmlns="" xml:lang="en"> 
                   <title> this is xhtml document</title>
            <body>  <p> this is a paragraph</p>   </body>  

xhtml example

xhtml attribute must be lowercase

<body ID="ONE">  <p> this is paragraph</p>
         </body>   this code completely wrong for xhtml  attribute must lowercase.
      <body id = "ONE">
          <p>this is demo </p>
                         </body> this is correct code.

xhtml attribute must closed with in quote:

<body  id="left_container><p> this is the paragraph<p>

                              <body id="left_container">
                              <p> this is sample</p>

xhtml element must closed matching(end tag):--

                              <p> this is paragraph
                              <h1> this is heading
<!-- this above code wrong in xhtml -- >
                              <p>this is paragraph </p>
                              <h1>this is heading  </h1>
                              <!-- write code for xhtml -->

xhtml element always in lowercase

  <body>            <P>this is a paragraph</p>

       <H1>this is heading</H1> <-- this code wrong in xhtml -->

      <p>this is para</p>
      <h1>this is heading</h1>