11
XHTML BY SANA MATEEN

Xhtml

Embed Size (px)

Citation preview

Page 1: Xhtml

XHTMLBY

SANA MATEEN

Page 2: Xhtml

• XHTML stands for EXtensible HyperText Markup Language

• XHTML is almost identical to HTML

• XHTML is stricter than HTML

• XHTML is supported by all major browsers

• Why Use XHTML?

• XHTML documents are XML conforming as they are readily viewed, edited, and validated with standard XML tools.

• XHTML documents can be written to operate better than they did before in existing browsers as well as in new browsers.

• XHTML documents can utilize applications such as scripts and applets that rely upon either the HTML Document Object Model or the XML Document Object Model.

• XHTML gives you a more consistent, well-structured format so that your webpages can be easily parsed and processed by present and future web browsers.

• You can easily maintain, edit, convert and format your document in the long run.

• Since XHTML is an official standard of the W3C, your website becomes more compatible with many browsers and it is rendered more accurately.

• XHTML combines strength of HTML and XML. Also, XHTML pages can be rendered by all XML enabled browsers.

• XHTML defines quality standard for your webpages and if you follow that, then your web pages are counted as quality web pages. The W3C certifies those pages with their quality stamp.

Page 3: Xhtml

The Most Important Differences from HTML:

• Document Structure• XHTML DOCTYPE is mandatory• The xmlns attribute in <html> is mandatory• <html>, <head>, <title>, and <body> are mandatory• XHTML Elements• 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• XHTML Attributes• Attribute names must be in lower case• Attribute values must be quoted• Attribute minimization is forbidden

Page 4: Xhtml

<!DOCTYPE ....> Is Mandatory• An XHTML document must have an XHTML DOCTYPE declaration.• A complete list of all the XHTML Doctypes is found in our HTML Tags

Reference.• The <html>, <head>, <title>, and <body> elements must also be present,

and the xmlns attribute in <html> must specify the xml namespace for the document.

• This example shows an XHTML document with a minimum of required tags:

Page 5: Xhtml

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>

Page 6: Xhtml

XHTML Elements Must Always Be Closed• This is wrong:• <p>This is a paragraph

<p>This is another paragraph• This is correct:• <p>This is a paragraph</p>

<p>This is another paragraph</p>

Page 7: Xhtml

Empty Elements Must Also Be Closed• 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" />

Page 8: Xhtml

XHTML Elements Must Be In Lower Case• This is wrong:• <BODY>

<P>This is a paragraph</P></BODY>

• This is correct:• <body>

<p>This is a paragraph</p></body>

XHTML Attribute Names Must Be In Lower Case

• This is wrong:• <table WIDTH="100%">• This is correct:• <table width="100%">

Page 9: Xhtml

Attribute Values Must Be Quoted

• This is wrong:• <table width=100%>• This is correct:• <table width="100%">

Page 10: Xhtml

Attribute Minimization Is Forbidden• Wrong:• <input type="checkbox" name="vehicle" value="ca

r" checked />• Correct:• <input type="checkbox" name="vehicle" value="ca

r" checked="checked" />

Page 11: Xhtml

How to Convert from HTML to XHTML

• Add an XHTML <!DOCTYPE> to the first line of every page• Add an xmlns attribute to the html element of every page• Change all element names to lowercase• Close all empty elements• Change all attribute names to lowercase• Quote all attribute values