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.
XHTML Links
- Wikipedia: XHTML
- W3Schools: XHTML
- W3C: XHTML1 versions (1.0 strict and transitional, 1.1, etc.)
- W3C: XHTML 1.0: technical specifications
- HTML Tidy Online: A tool for checking and cleaning up HTML files. Check the Output XHTML box.
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
andtitle
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
andstyle
elements have atype
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,
- Open the file, click File | Convert | XHTML, and save the file.
- 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:
- Press Ctrl-F, type
--#include
in the Find box, type-- include
in the Replace box, and click Replace All. - Click File | Convert | XHTML.
- Press Ctrl-F, type
-- include
in the Find box, type--#include
in the Replace box, and click Replace All.
- Press Ctrl-F, type
- 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.