Try my app Expense Manager @ google play and amazon store.

Tuesday, May 1, 2012

HTML Advanced tutorial 28 : What is XHTML

XHTML stands for EXtensible HyperText Markup Language. It is almost identical to HTML 4.01. It is a stricter and cleaner version of HTML. It is HTML defined as an XML application. It is Recommended by W3C. It is supported by all major browsers.

The following HTML code does not follow the HTML rules, but it will work fine in a browser.


<html>
<head>
<title>bad page</title>
<body>
<h1>Bad h1 element
<p>This is a paragraph
</body>



New in XHTML :
Following are the few differences in XHTML from HTML.

XHTML Elements Must Be Properly Nested :
In HTML, elements can be improperly nested within each other, for example

<b><i>This text is bold as well as italic</b></i>

While using XHTML, all elements must be properly nested within each other e.g ,

<b><i> This text is bold as well as italic </i></b>

XHTML Elements Must Always Be Closed :
In XHTML, non-empty elements must have a closing tag. For example

<p>This is a paragraph               ( This is wrong way )

<p>This is a paragraph</p>       ( This is correct way )

Empty Elements Must Also Be Closed :
In XHTML, empty elements must also be closed. For example
A line break      

<br>                 ( This is wrong way )         

<br />               ( This is correct way )

An image tag

<img src="img.jpg" alt="image">             ( This is wrong way )

<img src="img.jpg" alt="image" />           ( This is correct )

XHTML Elements Must Be In Lower Case :
In XHTML, tag names and attributes must be in lower case. For example

<BODY>                                              ( This is wrong way )
<P>This is a paragraph</P>
</BODY>



<body>                                                 ( This is correct way )
<p>This is a paragraph</p>
</body> 


XHTML Documents Must Have One Root Element :
All XHTML elements must be nested within the <html> root element. Child elements must be in pairs and correctly nested within their parent element. Following is the basic document structure used.

<html>
      <head>  



      </head>
     <body> 



     </body>
</html>


HTML Advanced tutorial 29 : XHTML Syntax Rules  >>
<<  HTML Advanced tutorial 27 : HTML Language Code

No comments:

Post a Comment

Follow by Email

Google+ Badge