Differences from HTML
There are a few difference between HTML and XHTML, but the main and most important of them is that you must close all tags within an XHTML document! Even tags that usually have no closing tag, such as images, now have to be closed! More information about how to change your tags can be found in the conversion tutorial.
Another difference includes the removal of certain HTML tags, mainly the presentation types. This is because XHTML is not supposed to be used to create presentation, but rather to just markup your pages for display - you should use Cascading Style Sheets instead! The <font> tag for example is no longer supported.
As XHTML is a much stricter version of HTML, there are certain rules that must be followed:
- The <title> tag must be used, and must be in the header section.
- All tags must be closed. So <p> must always be accompanied by </p>.
- Empty elements (tags without closing tags in HTML 4.01) must also be closed e.g. <br> is not valid, but <br /> is.
- All tags and attributes must be written in lowercase e.g. <BR /> is not valid, but <br /> is.
- Attributes must always be quoted. So <a href=example.html> is not valid, whereas <a href="example.html"> is valid.
- Attributes cannot be minimized e.g. <option selected /> is not valid, but <option selected="selected" /> is.
- You can no longer include a block level element within an inline element (e.g.<p> cannot be contained within <span></span>).
- Tags must be opened and closed in a strict order for example <b><i>good</i></b> and not <b><i>bad</b></i>.
- The <img /> tag must contain the alt attribute.
- The <style> tag must contain the type attribute e.g. <style type="text/css">.
These are about the only real differences, but it does take a while to get used to them! If you already know HTML then just take a look at the converting tutorial, which will show you how to change from HTML to XHTML. If you are new to making web pages, then I would suggest that you either use HTML first or start from scratch with the XHTML tutorials.