Major Differences between HTML and XHTML

There are several relatively small, but important, differences between HTML and XHTML. They are listed below, and you should attempt to adhere to them if you wish to receive full credit in the class.


Every HTML document should contain this dtd (document type declaration) at the very top:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Every transitional XHTML dtd must contain this info (copy and paste this at the top):


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
Your title here
</title>
</head>

 


Important: Notice the starting header information (including the title) is included so you don't need to include it in your new webpage. Start with the <body> tag. You should, however, change the title from Your title here to appropriate title.

You may wish to include a link to the XHTML validator...

<a href="http://validator.w3.org">Validate</a>
All tags must be lower case:

<img src="image.gif" alt="image">   not   <IMG SRC="IMAGE.GIF" ALT="IMAGE">


All tags must be closed. For HTML tags that do not require a close use: space/>

<img src="image.gif" alt="image" />


All attributes must be lower case and use quotes:

<body bgcolor="#000000">


Single word attributes such as <hr noshade> must contain a value:

<br noshade="noshade" />


All tags must be nested properly:

  <strong><em>some text</em></strong> not <strong><em>some text</strong></em> 


Image tags must use the alt attribute:

<img src="image.gif" alt="image" />


Special characters must use their corresponding name codes:

&=&amp


Links should include an id attribute as well as a name attribute:

<a href="http://google.com" id="google" name="google">Google</a>


Javascript must be placed in the <head> section with the following CDATA markers:

<script>
<[CDATA[
javascript...
]]>
</script>




Valid XHTML 1.0!