How to Convert HTML to XHTML
Advertisement
Ad
Converting HTML to XHTML
To convert HTML to valid XHTML, you must make the markup XML-compliant. Here's the step-by-step process.
Step 1: Update the Doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
Step 2: Lowercase All Tags & Attributes
<BODY> → <body>
<A HREF> → <a href>
Step 3: Close Every Tag
<br> → <br />
<img> → <img ... />
<li>item → <li>item</li>
Step 4: Quote All Attributes
<td width=50> → <td width="50">
Step 5: Validate
Run your page through the W3C Validator to catch any remaining errors.
FAQs
Are there automated tools?
HTML Tidy can auto-convert and clean up markup. More in our XHTML section.
Is conversion worth it today?
Usually not — migrating to HTML5 is the better modern choice.
