---
# System prepended metadata

title: 'DIFFERENCES BETWEEN XML, XHTML AND HTML WITH CODE EXAMPLES.'

---

DIFFERENCES BETWEEN XML, XHTML AND HTML WITH CODE EXAMPLES.

XHTML

XHTML stands for EXtensible HyperText Markup Language. It is a combination of extensible markup language XML and hypertext markup language HTML. It stored as a markup language format. It is case-sensitive, and every tag and attribute used inside must be in lowercase.

XHTML is almost identical to HTML but it is more strict than HTML. It is supported by all major browsers. It is mandatory to add a document label '<DOCTYPE>' at the beginning of the page and also close all the tags in strict residing order as they were declared. It is necessary to add quotes on every attribute. The file extensions used by XHTML are .xhtml, .xml and .xht

XHTML documents are well-formed and parsed using standard XML parsers, unlike HTML, which requires a lenient HTML-specific parser. 
    
    
    Below is a simple code example of XHTML,

    <!DOCTYPE html PUBLIC "-// W //DT XHTML 1.2 //EN"  
    " http : // www . myblogpost .org/T /xhtml12 / DT / xhtml12.dtd">  
    <html xmlns=http://www. myblogpost . org / 199 / xhtml >  
    <head>  
    	<title> XHTML document </title>  
    </head>  
        <body>  
        </body>  
    </html> 
     
In XHTML, the elements are always properly nested within each other, like this:
Correct:
`<b><i>`Some text`</i></b>`
Wrong:
`<b><i>`Some text`</b></i>`

Also, empty elements are always closed, like this:
Correct:
A break: `<br />`
A horizontal rule:`<hr />`
An image: `<img src="happy.gif" alt="Happy face" />` 
    
HTML
HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. HTML is a markup language, not a programming language, meaning it annotates text to define how it is structured and displayed by web browsers.

It forms the building blocks of all websites and is complemented by CSS for style and JavaScript for interactivity. It is an extension of standard generalized markup language (SGML). It stored in a document file format. It is not case sensitive as there is no mandatory rule to write the entire mark up in uppercase or lower case. It is not mandatory to add document label '<DOCTYPE>'at the top of every page. We can close any tag anytime and anywhere as per our needs. We can add attributes without any quotes.The extensions used by HTML are .html and .htm

In a nutshell, HTML is all about organizing and displaying information on a webpage. We can think of it as the bones or structure of a webpage.

Here is a basic code example of HTML.

    <!DOCTYPE html>  
    <html>  
    	<head>  
    		<title>Title</title>  
    	</head>  
    <body>  
   		 <h1>Hello World</h1>  
   		 <p>welcome this is your first HTML program</p>  
    </body >  
    </html >  

In HTML, empty elements are not always closed, like this:
A break: `<br>`
A horizontal rule: `<hr>`
An image: `<img src="happy.gif" alt="Happy face">` 
 
    


XML
Extensible Markup Language (XML) lets you define and store data in a shareable manner. XML supports information exchange between computer systems such as websites, databases, and third-party applications. Predefined rules make it easy to transmit data as XML files over any network because the recipient can use those rules to read the data accurately and efficiently.
XML documents may begin with an XML declaration that describes some information about themselves.

An example is <?xml version="1.0" encoding="UTF-8"?>.

The following is an example of a simple XML code file:

`<?xml version="1.0" encoding="UTF-8"?>`
`<library>`
     `<book>`
          `<title~>The Fire Next Time</title>`
          `<author>Baldwin, James</author>`
     `</book>`
     `<book>`
          `<title>Beloved</title>`
          `<author>Morris, Toni</author>`
     `</book>`
     `<book>`
          `<title>The Messiah of Stockholm</title>`
          `<author>Ozick, Cynthia</author>`
     `</book>`
`</library>`
    
Strict validation of XML code means that, if there are errors in the code, it will fail when it is processed for output. Users can then correct the XML code so it can be successfully processed.