Comparison between HTML and XHTML

Source: Internet
Author: User

The following content is translated from: http://reference.sitepoint.com/html/html-vs-xhtml
1. HTML case insensitive, XHTML sensitive, only lowercase tags
2. HTML tags do not necessarily require closure, but XHTML tags must be closedin HTML, the following is valid:<p>this is my first paragraph.<p>this was my second Paragraph.<p>and here's the last one..in XHTML, however, you must instead:<p>this is my first paragraph.</p><p>this was my second paragraph.</p><p>and here ' s Last one.</p>
3, HTML even allow some tags (html,head,body,tbody) do not need to start tag, but do not recommend this

4. XHTML requires that empty elements such as IMG must be prefixed with the Terminator "/":<elementname attribute= "AttributeValue"/&GT;Application/xhtml+xml "MIME type, empty element can use start and end tag. such as IMG tags can be written as:</img>

5. XHTML requires that the values of all attributes be enclosed in quotation marks (both single and double quotes), such as class= "Gallery", and cannot be written as class=gallery.

In HTML, property values can have no quotation marks


6, XHTML must have


7. XHTML can use similar <p/> to directly indicate that the element has no content, HTML is not.


8. All attributes in XHTML must be written as: Property = "Property value", while HTML allows some boolean-type properties to write only property names, without writing property values.

as in HTML, the selected input element can be written like this: <input type= "checkbox" Name= "Chknewsletter" checked >;

and in XHTML must be written:<input type= "checkbox" Name= "Chknewsletter" checked= "checked";


9. In XHTML, the language in which the element content is set uses the Xml:lang attribute, which is used in HTML with the lang attribute.


10. In XHTML, you need to set the correct MIME type on the HTTP header: "Application/xhtml+xml" (the best option), "Application/xml" (acceptable), or "Text/xml" (which isn ' t recommended).


11.XHTML,text encoding should be set within the XML declaration, not in the HTTP headers (although doing the LAT TER is still allowed).

The space between the attributes of an element is no matter how much, as long as there is at least one line.


12. XHTML is also very different in handling script and stylesheet: document.write () and Document.writeln () do not working in XHTML



Comparison between HTML and XHTML

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.