---
title: "XHTML versus HTML"
subject: "Web Technology"
chapter: 2
key: "semester_7/web_technology:xhtml-vs-html"
source: https://www.bctengineer.com/q/semester_7/web_technology/xhtml-vs-html
site: BCT Engineering
---

# XHTML versus HTML

Web Technology · Chapter 2: Web basics

- Asked in: 2076 Chaitra, 3 marks; 2068 Chaitra (old course), 5 marks (asked 2 times)
- Video: [HTML Vs XHTML Explained | Difference Between HTML And XHTML | HTML For Beginners | SimpliCode](https://www.youtube.com/watch?v=b8ECUJw_X1o) — SimpliCode
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/web_technology/xhtml-vs-html
- Whole chapter: https://www.bctengineer.com/md/semester_7/web_technology/chapter-2

## Question

How is XHTML different from HTML?

## Short answer

XHTML is a stricter, XML-based reformulation of HTML. It requires lowercase tags, closed elements, quoted attributes, proper nesting, and a mandatory DOCTYPE, whereas HTML is more forgiving, allowing optional tags and case-insensitivity.

## Answer

**HTML** (HyperText Markup Language) is the standard language for web pages and has loose syntax rules. **XHTML** (Extensible HTML) is HTML reformulated as an XML application, so it must follow XML's strict rules.

| Basis | HTML | XHTML |
|---|---|---|
| Based on | SGML | XML |
| Tag case | Case-insensitive (`<P>` = `<p>`) | Tags and attributes must be lowercase |
| Closing tags | Some may be omitted (`<p>`, `<li>`) | Every element must be closed |
| Empty elements | `<br>`, `<img ...>` | `<br />`, `<img ... />` |
| Nesting | Wrong nesting often tolerated | Must be properly nested |
| Attribute values | Quotes optional | Must be quoted: `width="100"` |
| Attribute minimisation | `<input checked>` allowed | `checked="checked"` required |
| Root element | `<html>` optional in practice | `<html xmlns="http://www.w3.org/1999/xhtml">` required |
| DOCTYPE | Optional/relaxed | Mandatory |
| Error handling | Browser forgives errors | Parser stops on a well-formedness error |
| MIME type | text/html | application/xhtml+xml (or text/html) |
| Parsing | Not XML-parsable | Can be processed by XML tools |

Example:
```html
<!-- HTML -->
<p>First<br>
<input type=text name=a>

<!-- XHTML -->
<p>First<br />
<input type="text" name="a" /></p>
```
XHTML therefore gives cleaner, well-formed, more portable code, but HTML5 later became the main standard because it is more forgiving.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is XHTML based on, compared with HTML?
   A. XHTML is based on XML; HTML on SGML
   B. XHTML on SGML; HTML on XML
   C. Both on XML
   D. Both on SGML
   Answer: A. XHTML is HTML reformulated as an XML application. (Key point: Basis)

2. Which is the correct XHTML form of a line break?
   A. <br>
   B. <br />
   C. <BR>
   D. <br/ >
   Answer: B. XHTML requires empty elements to be closed, written <br />, and lowercase. (Key point: Empty elements)

3. What happens in XHTML if the document is not well-formed?
   A. The browser silently fixes it
   B. It is shown as plain HTML
   C. The parser stops with an error
   D. Only a warning is displayed
   Answer: C. XHTML parsing is strict, unlike the forgiving HTML parsing. (Key point: Error handling)

4. Which input is valid XHTML?
   A. <input type=checkbox checked>
   B. <INPUT TYPE=checkbox CHECKED>
   C. <input type="checkbox" checked>
   D. <input type="checkbox" checked="checked" />
   Answer: D. XHTML needs quoted values, lowercase names and no attribute minimisation. (Key point: Attribute rules)
