Questions to note about writing XHTML and how to differentiate from HTML

Source: Internet
Author: User
Tags compact empty end lowercase
xhtml| Difference | problem

the document must be well choreographed

Elements must be nested, although the SGML rules stack illegally, but existing browsers generally allow cascading.

Correct: nested elements.

<p>here is a emphasized <em>paragraph</em>.</p>

Incorrect: cascading elements.

<p>here is a emphasized <em>paragraph.</p></em>

Nesting and cascading

Element and attribute names must be lowercase

XHTML documents must use lowercase for all HTML element and attribute names. Because XML is case sensitive, this difference is necessary. such as < li > and < li > are different labels.

for non-null elements, the end tag must be used

In SGML based HTML, some implicitly end-meaning elements allow the end tag to be ignored. In xml-based XHTML, this omission is not allowed. All elements must have an end tag, except for elements declared empty in the DTD.

Correct: The end of the element.

<p>here is-a paragraph.</p><p>here is another paragraph.</p>

Incorrect: element not closed.

<p>here is a paragraph.<p>here is another paragraph.

XHTML requires code writing to be very standard, and may sometimes be allowed by browsers, but not through XHTML validation.

property value must be in quotation marks

All attributes must be in quotes, even numbers.

Correct: attribute value in quotation marks

<table rows= "3" >

Incorrect: property value not in quotation marks.

<table rows=3>

Very basic specification, which should be the same in HTML.

attribute Minimization

XML does not support the minimization of attributes. Attribute value pairs must be fully written. Property names such as compact,checked cannot be specified in an element without specifying a property value.

Correct: No properties minimized

<DL compact= "compact" >

Incorrect: Minimizing properties

<DL compact>

The default properties also need to be fully written out.

empty Element

An empty element must either have an end tag, or the start tag ends with/>.

Correct: An empty element that ends

<br/>

Error: Empty label not closed

<br>

This is very important and it is easy to make mistakes.

Choreography Good (well-formedness) is a new concept introduced in XML. Essentially, this means that the element must have an end tag, or it must be written in a special way.



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.