what is the difference between html and xhtml


Category: HTML Tags: HTML

Today someone asked me what is the html and what is xhtml. and what are the main difference in both of them, because both are looking same as sights of code.

Like 2 People
Asked on 30 July 2013
Nikhil Joshi

Nikhil Joshi
Ceo & Founder at Dotnetlovers
Atricles: 132
Questions: 9
Given Best Solutions: 9 *

Answers:

Nikhil Joshi
HTML (Hyper Text Markup Language) :- is the main markup language for creating web pages and other information that can be displayed in a web browser.
HTML is written in the form of HTML elements consisting of tags enclosed in angle brackets (like <html>), within the web page content. HTML tags most commonly come in pairs like <h1> and </h1>, although some tags represent empty elements and so are unpaired, for example <img>.
The purpose of a web browser is to read HTML documents and compose them into visible or audible web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page.

XHTML (Extensible HyperText Markup Language) :- is a family of XML markup languages that mirror or extend versions of the widely used Hypertext Markup Language (HTML), the language in which web pages are written.
While HTML (prior to HTML5) was defined as an application of Standard Generalized Markup Language (SGML), a very flexible markup language framework, XHTML is an application of XML, a more restrictive subset of SGML. Because XHTML documents need to be well-formed, they can be parsed using standard XML parsers—unlike HTML, which requires a lenient HTML-specific parser.

Difference between HTML and XHTML :- XHTML is not so much different from HTML 4.01 standard. The major differences are:

  • XHTML elements must be properly nested

  • XHTML elements must always be closed.

  • XHTML elements must be in lowercase.

  • XHTML documents must have one root element.


  • Basically, XHTML is HTML (all the html tags are found in XHTML) that follows the rules of XML (because it is a family of XML).

    For example HTML code would be:
    <html> 
    
    <head>
    <title>This is a title</title>
    </head>
    <body>
    <p>Hello world!</p>
    </body>
    </html>

    And the code of XHTML would be:
    <?xml version="1.0" encoding="UTF-8"?> 
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>XHTML 1.0 Strict Example</title>
    <script type="application/javascript">
    <![CDATA[
    function loadpdf() {
    document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
    }
    ]]>
    </script>
    </head>
    <body onload="loadpdf()">
    <p>This is an example of an
    <abbr title="Extensible HyperText Markup Language">XHTML</abbr> 1.0 Strict document.<br/>
    <img id="validation-icon"
    src="http://www.w3.org/Icons/valid-xhtml10"
    alt="Valid XHTML 1.0 Strict"/><br />
    <object id="pdf-object"
    type="application/pdf"
    data="http://www.w3.org/TR/xhtml1/xhtml1.pdf"
    width="100%"
    height="500"/>
    </p>
    </body>
    </html>

    For more refrence see here:
    https://en.wikipedia.org/wiki/HTML
    http://en.wikipedia.org/wiki/XHTML
    Like 2 People on 30 July 2013

    You are not loggedin, please login or signup to add comments:

    Existing User

    Login via:

    New User



    x