Facebook
Banner
XMPP JavaScript Library READ MORE

What is XHTML?

HTML, Sachin Puri, 2011-04-06 00:10:23

What is XHTML?

XHTML (eXtensible HyperText Markup Language) is nothing but just HTML 4.01 with restrictions on following the standard. While writing a XHTML document we have to follow all the rules and standards. 

 

Why XHTML?

The main reason behind XHTML is to maintain the same coding standard among all the web sites so that web pages render properly in all the web browsers. XHTML is a cleaner version of HTML4.01. A document written using XHTML can be rendered properly by all the web browsers. if you already know HTML then it will take just 10 minutes to learn XHTML. Just follow the rules give below and enjoy your XHTML programming. 

 

XHTML rules

Rule 1. All the tags must be closed, even empty elements 

Wrong Right

<div>

    <span>Home Page

    <br>

<div>

      <span>Home Page</span>

     <br/>

</div>


 

 

 

 

 

Rule 2. All the tags and attributes should be written in lower case.

Wrong Right

<HTML>

    <HEAD>

        <TITLE>Home Page</TITLE>

    </HEAD>

    <BODY>

    </BODY>

</HTML>

 

<html>

    <head>

        <title>Home Page</title>

    </head>

    <body>

    </body>

</html>

 

 

 

 

 

 

 

 

 


 

Rule 3. All the tags should be properly nested

Wrong Right

<b><i>Hello World</b></i>

<b><i>Hello World</i></b>


 

 

 

Rule 4. Image (img) tag should contain 'alt' attribute.

Wrong Right

<img src="image1.jpeg"/>

<img src="image1.jpeg" alt="Image 1"/>


 

 

 

Rule 5. Specify "type" attribute in <script> and <style> tags.

Wrong Right

<style>

</style>

 

<script>

</script>

 

<style type="text/css">

</style>

 

<script type="text/javascript">

</script>

 


 

 

 

 

 

 

 

Rule 6. <style> tags should only be declared in <head></head> section.

Wrong Right

<body>

    <style>

    </style>

</body>

 

<head>

    <style>

    </style>

</head>

 


 

 

 

 

 

 

Rule 7. Attrubute values must be quoted 

Wrong Right

<div width=500px></div>

<div width="500px"></div>

 

 


 

Rule 8. Attrubutes can't be minimized 

Wrong Right

<input type="checkbox" name="chk1" checked />

<input type="checkbox" name="chk1" checked="checked" />

 


 

 

Rule 9. Declaring DOCTYPE is mandatory in XHTML



Rule 10. html, head, title, body tags must be defined 

Add Your Comment
   
    Yes! I want to receive all comments by email

No Comments Posted Yet. Be the first one to post comment