XHTML stands for EXtensible Hyper Text Markup Language

XHTML is HTML and XML combined.

Now that you have learnt the basic definitions, now we must obey a few rules of xHTML.

Always Close Your Tags



You must always close your html tags after using them.

Example :

<p><u>Hello everybody</p>



Correction :

<p><u>Hello everybody</u></p>



Also, this html code might look like you shouldn't close it, because people normally provide you with one code when it is opening. But, do not be fooled. You must always close your tags when ending.

Example :

Hello

<hr>

Hello

Correction :

Hello

<hr/>

Hello

Example Two :

Hello <br>
Hello

Correction :

Hello <br/>
Hello



Do Not Use CAPs

Try avoid using CAPs for your html codes, and stick with the lower cases. Also, I suggest you stay away from some online script generators.

Example :

<HEAD><META NAME="blah" CONTENT="blahblah" /></HEAD>

<BODY>
<P><U>Hello everyone</U></P>
<P><I>It is nice to meet you all</I></P>
</BODY>

Correction :

<head><meta name="blah" content="blahblah" /></head> <br/><br/>

<body>
<p><u>Hello everyone</u></p>
<p><i>It is nice to meet you all</i></p>
</body>



Documents Must Only Have One Root

You must only have one root for your xhtml documents. The root is . You must always have all of your html codes after that root. Remember to follow the basic html structure from my html tutorial :

<html>

<head> </head>

<body> </body>

</html>

I just removed the heading and paragraph text.

Use Quotes When Needed

You know those html codes that you see and use everyday. Take a look at this example html code :

<a href=http://www.iwebbuddy.com target=_blank><img src=http://i86.servimg.com/u/f86/14/46/24/48/iwebbu10.gif border=0 height=31 width=88 alt=iwebbuddy.com></a>

It's just the smallest things that causes big problems. Remember, always use quotes to defind the value of the property. ( "value" )

Example of the right way :

<a href="http://www.iwebbuddy.com" target="_blank"><img src="http://i86.servimg.com/u/f86/14/46/24/48/iwebbu10.gif" border="0" height="31" width="88"></a>



XHTML Tags Must Be Nested Properly

When adding your codes, always place them in the right format for XHTML.

This means, you have to arrange your html tags a certain way to make it look clean and neat.

Example :

<b><u>Hello everyone</u></b>



Bad Example :

<b><u>Hello everyone</b></u>



This bad example will work for html, but please try to avoid it when using xHTML.

Do Not Shorten Attributes

Try not to shorten attributes likes these :

<option selected>
<input checked>



This is the correct way to use them for XHTML :

<option selected="selected" />
<input checked="checked" />



If you see anymore html codes above that is seen in the wrong way for XHTML, then translate them to the correct way.

DOCTYPE Declaration

Every XHTML document must have a 'DOCTYPE' declaration and the page must include the html, head and body tags.

When building a web page with a DOCTYPE, then stick in the DOCTYPE first. The DOCTYPE is not a part of the xhtml document.

Example :

<!DOCTYPE ( add in one ) >
<html>
<head> <title> blah blah blah blah </title> </head>
<body> blah blah blah blah </body>
</html>

Here are three DOCTYPEs that might interest you.

The Strict DTD



This DOCTYPE contains elements and attributes that have not been deprecated or do not appear in frames. You should use this if you are creating a website that will have CSS. It is best to use this DOCTYPE on web pages with no extra html tags.

The Transitional DTD



This DOCTYPE contains everything in the strict DTD ( the DOCTYPE above ), deprecated elements and attributes.

The Frameset DTD



This DOCTYPE contains everything in the frameset DTD ( the DOCTYPE above ), and frames. It should be used if you have frames on your web page.