Here's how simple it is, according to Peter-Paul Koch:
In practice, the following rules have been added to HTML for writing XHTML:
- 1. Make sure all your tags are lower case.
- 2. Close all your tags. In the case of tags that don?t have a closing tag, like <IMG> or <BR>, add a slash to the end of the tag: <img />, <br />.
- 3. Nest tags correctly. No more <B><P>text</B></P>, but <p><b>text</b></p>.
- 4. Put quotes around all attribute values. No more <P ALIGN=center> but <p align="center">.
The good news is that current browsers don?t have any problems with XHTML. After all, rule 1, 2 and 4 are already optional in HTML, while rule 3 is required (even though in most cases browsers ignore nesting errors). The only really new one is rule 2a. However, this rule only leads to problems when you write <br/> without the space. Now the browser sees a br/ tag that it doesn?t know, so it doesn?t do anything. Inserting a space solves this problem. If you write <br /> the browsers see a br tag with an unknown attribute /. The br is executed, the unknown attribute is ignored.