Skip to main content
D
HTML
HTML vs XHTML

HTML vs XHTML

XHTML enforces strict rules on traditional HTML.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

XHTML is a stricter version of HTML based on XML. It forces developers to close every tag and nest elements perfectly. Modern web development prefers HTML5 due to its flexibility and rich features.

Syntax

Syntax
1<!-- xhtml strictness -->
2<br />

Example

Example
1<!-- this shows strict XHTML -->
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml">
4  <head>
5    <meta charset="UTF-8" />
6    <title>XHTML</title>
7  </head>
8  <body>
9    <p>All tags must close.</p>
10  </body>
11</html>

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • XHTML requires perfectly closed tags.
  • HTML5 allows more relaxed syntax.
  • XHTML demands lowercase tag names.
  • HTML5 replaced XHTML as the standard.

Up Next

Continue your journey with the next topic.

Go to HTML Forms