Change Font Size:

Difference between HTML and XHTML

This article mainly on the difference between HTML and XHTML. In simple terms, can be considered XHTML XML version of HTML in order to comply with requirements of XML, XHTML syntax more stringent requirements on more.

Following is XHTML relatively few big distinction between HTML:

  • XHTML called for correctly nested
  • XHTML all the elements must be closed
  • XHTML distinguish between upper and lower case
  • XHTML attribute value use double quotes
  • XHTML replaced by id attribute name attribute
  • XHTML handling special characters

XHTML called for correctly nested

Following is the correct nest:

<p> NT22 unique.

Following is the wrong nested:

<p> NT22 unique

.

XHTML all the elements must be closed

Following is XHTML relatively few big distinction between HTML.

In HTML, for example <p>,

  • Such markings, you can not write </ p>,
  • , But in XHTML, written request must be closed labeling (Closing Tag).

    For example:

    <p> NT22 very seriously.

    Should be written:

    <p> NT22 very seriously. </ P>

    Dealing with air element

    Some air elements, XHTML, in the wording of the " />" before spaces and slash. For example, should be written.

    Following is the air element examples:

    <br />

    <hr />

    <img Src = "/images/adpics/1/b027.jpg" alt = "nt22" />

    <link Rel="stylesheet" href="/styles/nt22.css" type="text/css" />

    <meta Http-equiv="content-type" content="text/html; charset=UTF-8" />

    XHTML distinguish between upper and lower case

    HTML does not distinguish between upper and lower case, but XHTML is case-sensitive.

    XHTML all decals and attributes must be lowercase lowercase.

    All decals and attributes must be lowercase. For example: It is case-sensitive.

    For example:

    <IMG SRC = "/images/adpics/1/b027.jpg" Alt = "nt22" />

    Should be written:

    <img Src = "/images/adpics/1/b027.jpg" alt = "nt22" />

    XHTML attribute value use double quotes

    HTML is not mandatory for attribute values and double quotes. For example, you can write:

    <table Cellspacing = 0>

    <input Checked>

    However, in XHTML, should be written:

    <table Cellspacing = "0" />

    <input Checked = "checked" />

    XHTML replaced by id attribute name attribute

    Before spaces and slash. For example <br> should be written <br!

    HTML many elements, such as a, applet, frame, iframe, and map img, a name attribute. In XHTML, is to repeal, and replace it with id attribute.

    For example:

    <img Src="nt22.gif" name="nt22 logo" />

    Should be written:

    <img Src="nt22.gif" id="nt22 logo" />

    XHTML handling special characters

    & Should be written in the XHTML & Lane.

    CSS designated by the class, is case-sensitive.

    For example:

    You & Me

    Many elements, such as a, applet, frame, iframe.

    Should be written:

    You & Me

    For example: For example:: The following are examples of empty elements: It should be written: Closing.

    If there Javascript code embedded in XHTML, it should be written:

    <script Type="text/javascript" /> //<![ CDATA [

    ...

    //]]></ Script>

    Browser perspective

    These are protocol standards from the point of view of the problem. If the browser from the angle of view on this issue, the situation is somewhat different.

    Consider, if not strictly written to XHTML browsers how do? Is not a dialog box will pop up, read, "the development of this site technical staff Commissioner However, the writing is not authentic XHTML documents Our do not show"? Obviously, if the browser cause like this, it will not lose money was used.

    From the browser several different perspective above, are generally below the test results (IE and Firefox I tested):

    • XHTML correct nested request: If you do not have nested, the browser will try to help you nested.
    • XHTML all the elements must be closed: If you have not closed, the browser will try to help you close.
    • XHTML case-sensitive: You insist on written in capital letters, the browser help you converted into lowercase.
    • Attribute value use double quotes: You insist on not Kenjia, the browser and help you.
    • Dealing with special characters: You & Me or You & Me or browser can read.
    • Replaced by id attribute name attribute: You can also insist on using name.

    If you started in the document DocType designated as XHTML, it is necessary to pay attention to. Tag to the class specified by the CSS, is case-sensitive. For example, you define a CSS as follows,

    <style>
    . Hello (...)
    </ Style>

    When you use the languages,

    <p Class="Hello" /> ......

    CSS is that this will not be used. To a positive view on this issue, which allows you to spend more named after Style, is a good thing.

    XHTML standard of the future

    From the standard-setter mind, the development of XHTML standard HTML is trying to become a strict standard XML format, this will inevitably lead to a result, is from HTML to XHTML standards lead to the escalation of the fault-tolerant capability reduces. To their own web pages source document written strictly that of course is a good thing, but it is impossible to require a standard browser lower their fault-tolerant capability.

    To their own web pages source document written strictly that of course is a good thing?

    XHTML 1.0 is compatible with HTML 4.01 standard is a good agreement, allows developers to write code at the same time through a number of tools to check the legitimacy of the code, although the user, produced pages and HTML 4.01 is not much different than . For you to write a new website, the use of XHTML 1.0 is a good choice.

    Javascript code in XHTML.

    XHTML 1.1 standard browser no longer supports the original fault-tolerant, it is a standard-setter possessed by the devil classic example of this from the academic standards it is very pure, but for the browser, this is a dull, clumsy, too standards. Therefore, all current human development browsers did not comply with the so-called pure XHTML 1.1 standards, as long as your browser code can be read, he will show the good, and not jump out shells frame error.

    From the view of the trend of development, not a standard browser obedience, it is tantamount to no meaningful standards. From the realization of the browser point of view, the new agreement in the original HTML only on the basis of expanding capacity to increase fault tolerance, and can not be reduced ability to reduce the fault-tolerant. So the new agreement, only expand the capacity increase will be part of the fault-tolerant adopted, and other parts of it are just empty talk.