Home > Resources > Web Development > Web Tips > XHTML


What | Links | Features | How

What is XHTML?

XHTMLis a strict version of HTML that works in many types of browsers and is therefore accessible. In 2000, XHTML replaced HTML 4 as the recommended standard for creating Web pages.

All CSU Libraries Web pages should be converted to XHTML.


What are some ways that XHTML is more strict than HTML?

  • All documents start with a DOCTYPE declaration that indicates the document is XHTML.
    • <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  • All documents have html, head, body and title elements.
  • All elements are fully contained inside other elements, without overlap.
    • <h1>heading</h1><p>paragraph</p> not <h1>heading<p>paragraph</h1></p>
  • All single tag elements end with />.
    • <meta />, <img /> or <br />
  • All other elements have a closing tag.
    • <p>paragraph</p> , <li>list item</li>
  • All elements and attributes are lowercase. (Attribute values can be uppercase, though.)
    • <p id="P1"> not <P ID="P1">
  • All attribute values are surrounded by quotation marks.
    • id="P1"
  • All script and style elements have a type attribute.
    • <style type="text/css">
  • All images have an alt attribute.
    • <img src="csulogo.jpg" width="120" height="80" alt="CSU Logo" />

How do I use XHTML?

Using Macromedia Dreamweaver,

  • To convert any existing HTML document to XHTML,
    1. Open the file, click File | Convert | XHTML, and save the file.
    2. If Dreamweaver complains that the code is locked by a template or translator and cannot convert to XHTML, temporarily change the SSIs into comments as follows:
      1. Press Ctrl-F, type --#include in the Find box, type -- include in the Replace box, and click Replace All.
      2. Click File | Convert | XHTML.
      3. Press Ctrl-F, type -- include in the Find box, type --#include in the Replace box, and click Replace All.
  • To automatically create XHTML documents,
    • Click Edit | Preferences | New Document, and check Make document XHTML compliant.
  • To validate the document:
    • Click Edit | Preferences | Validator, check XHTML 1.0 Transitional, and click OK.
    • Click File | Check Page | Validate Markup, and click on an error message that appears at the bottom to go to the line needing correction.