How does xhtml differ from html ?
These are the main xhtml rules. Consult www.w3c.org for a complete list.
Html vs xhtml | Html | xhtml |
1. Tags and attributes must be in lower case | <TD BGCOLOR=ffcc33> | <td bgcolor="#FFCC33"> |
2. Attribute values must be quoted (see above example bgcolor="#FFCC33") |
||
3. Elements must nest, no overlapping. This is actually illegal in html as well but tolerated by most browsers. |
<B><I>text</b></i> | <b><i>text</i></b> |
4.All elements must be closed (Note even the so-called empty img tag has a closing / Commonly used empty tags include <hr /> <br />) |
Some text<p><img src="rose.gif" alt='rose'> | <p>Some text</p><img src="rose.gif" alt='rose' /> |
5. Attribute value pairs cannot be minimized | <TD nowrap> or <table border> | <td nowrap="nowrap"> or <table border='1'> |
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <title> Minimal xhtml Document</title></head>