freecoding.school100% FREE · NO SIGNUP
The Old NetISSUE #3 of 60

xhtml vs html · the differences

Pixel PeteVSQuirks Mode
Pixel Pete saysXHTML differs from HTML in five rules: lowercase, close everything, quote attributes, nest correctly, one root.

The practical differences from HTML: tag and attribute names must be lowercase; every element must be closed (including void ones as <br />); attribute values must be quoted; elements must nest without overlap; and the document needs a single root with the XHTML namespace. Break any rule and a true XHTML parser rejects the page.

Power-ups you unlock

Quirks Mode attacks — common mistakes

Boss battleTake an HTML line breaking three of these rules and fix all three.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>HTML (loose):  &lt;P class=lead&gt;Hi&lt;BR&gt;
XHTML (strict):&lt;p class="lead"&gt;Hi&lt;br /&gt;&lt;/p&gt;</pre></body></html>
▶ Open the interactive comic issue
‹ Why Xhtml Existed · The Strictness PitchXhtml Syntax Rules · The Five Musts ›