Rizwan Abbasi’s Blog











{ستمبر 10, 2006}   XHTML Vs HTML

You can prepare yourself for XHTML by starting to write strict HTML.

How To Get Ready For XHTML
XHTML is the next generation of HTML, but it will of course take some time before browsers and other software products are ready for it.
In the meantime there are some important things you can do to prepare yourself for it. As you will learn from this tutorial, XHTML is not very different from HTML 4.01, so bringing your code up to 4.01 standards is a very good start. Our complete HTML 4.01 reference can help you with that.
In addition, you should start NOW to write your HTML code in lowercase letters, and NEVER make the bad habit of skipping end tags like the

.
Happy coding!

The Most Important Differences:
• XHTML elements must be properly nested
• XHTML documents must be well-formed
• Tag names must be in lowercase
• All XHTML elements must be closed

Elements Must Be Properly Nested
In HTML some elements can be improperly nested within each other like this:
This text is bold and italic
In XHTML all elements must be properly nested within each other like this:
This text is bold and italic

Note: A common mistake in nested lists, is to forget that the inside list must be within a li element, like this:

  • Coffee
  • Tea
    • Black tea
    • Green tea
  • Milk

This is correct:

  • Coffee
  • Tea
    • Black tea
    • Green tea
  • Milk

Notice that we have inserted a

tag after the

tag in the "correct” code example.

Documents Must Be Well-formed
All XHTML elements must be nested within the root element. All other elements can have sub (children) elements. Sub elements must be in pairs and correctly nested within their parent element. The basic document structure is:


Tag Names Must Be In Lower Case
This is because XHTML documents are XML applications. XML is case-sensitive. Tags like
and
are interpreted as different tags.
This is wrong:

This is a paragraph

This is correct:

This is a paragraph

All XHTML Elements Must Be Closed
Non-empty elements must have an end tag.
This is wrong:

This is a paragraph

This is another paragraph
This is correct:

This is a paragraph

This is another paragraph

Empty Elements Must Also Be Closed
Empty elements must either have an end tag or the start tag must end with />.
This is wrong:
This is a break
Here comes a horizontal rule:


Here’s an image Happy face
This is correct:
This is a break

Here comes a horizontal rule:


Here’s an image Happy face

IMPORTANT Compatibility Note:
To make your XHTML compatible with today’s browsers, you should add an extra space before the "/” symbol like this:
, and this:


.

Advertisements


جواب دیں

Please log in using one of these methods to post your comment:

WordPress.com Logo

آپ اپنے WordPress.com اکاؤنٹ کے ذریعے تبصرہ کر رہے ہیں۔ لاگ آؤٹ / تبدیل کریں )

Twitter picture

آپ اپنے Twitter اکاؤنٹ کے ذریعے تبصرہ کر رہے ہیں۔ لاگ آؤٹ / تبدیل کریں )

Facebook photo

آپ اپنے Facebook اکاؤنٹ کے ذریعے تبصرہ کر رہے ہیں۔ لاگ آؤٹ / تبدیل کریں )

Google+ photo

آپ اپنے Google+ اکاؤنٹ کے ذریعے تبصرہ کر رہے ہیں۔ لاگ آؤٹ / تبدیل کریں )

Connecting to %s

et cetera
%d bloggers like this: