Doc1 - XHTML is a combination of HTML and XML (EXtensible...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: XHTML is a combination of HTML and XML (EXtensible Markup Language). XHTML consists of all the elements in HTML 4.01 combined with the syntax of XML . The Most Important Differences: XHTML is not very different from the HTML 4.01 standard. So, bringing your code up to the 4.01 standard is a 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 skip ending tags (like </p>). 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 1- XHTML Elements Must Be Properly Nested In HTML, some elements can be improperly nested within each other, like this: <b><i>This text is bold and italic</b></i> In XHTML, all elements must be properly nested within each other, like this: <b><i>This text is bold and italic</i></b> Note: A common mistake with nested lists, is to forget that the inside list must be within <li> and </li> tags. This is wrong: <ul> <li>Coffee</li> <li>Tea <ul> <li>Black tea</li> <li>Green tea</li> </ul> <li>Milk</li> </ul> This is correct: <ul> <li>Coffee</li> <li>Tea <ul> <li>Black tea</li> <li>Green tea</li> </ul> </li> <li>Milk</li> </ul> Notice that we have inserted a </li> tag after the </ul> tag in the "correct" code example. 2- XHTML Elements Must Always Be Closed * Non-empty elements must have an end tag. This is wrong: <p>This is a paragraph 1 <p>This is another paragraph This is correct: <p>This is a paragraph</p> <p>This is another paragraph</p> * Empty Elements Must Also Be Closed Empty elements must either have an end tag or the start tag must end with />. This is wrong: A break: <br> A horizontal rule: <hr> An image: <img src="happy.gif" alt="Happy face"> This is correct: A break: <br /> A horizontal rule: <hr /> An image: <img src="happy.gif" alt="Happy face" /> 3- XHTML Elements Must Be In Lower Case The XHTML specification defines that the tag names and attributes need to be lower case. This is wrong: <BODY> <P>This is a paragraph</P> </BODY> This is correct: <body> <p>This is a paragraph</p> </body> 4- XHTML Documents Must Have One Root Element All XHTML elements must be nested within the <html> 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: <html> <head> ... </head> <body> ... </body> </html> Some More XHTML Syntax Rules: Attribute names must be in lower case Attribute values must be quoted Attribute minimization is forbidden The id attribute replaces the name attribute The XHTML DTD defines mandatory elements 1- Attribute Names Must Be In Lower Case This is wrong: <table WIDTH="100%"> This is correct: <table width="100%"> 2 2- Attribute Values Must Be Quoted This is wrong: <table width=100%> This is correct: <table width="100%"> 3- Attribute Minimization Is Forbidden...
View Full Document

This note was uploaded on 02/06/2012 for the course FACULTY OF WXGE6320 taught by Professor Noraini during the Winter '09 term at University of Malaya.

Page1 / 16

Doc1 - XHTML is a combination of HTML and XML (EXtensible...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online