Loading...

HTML XHTML

Previously, Server-Sent Events (SSE) taught the browser to open EventSource and receive a one-way server text stream — live updates, not document syntax history. This lesson leaves streams behind and closes the HTML course’s optional history track with XHTML: HTML written under XML rules. You may still meet old books, certificates, or snippets labeled XHTML 1.0 / 1.1. Scope stays practical — what was stricter, what HTML5 changed, which habits still help — not XML schemas, application/xhtml+xml MIME battles, or a full polyglot publishing course.

Why XHTML in an HTML course

Beginners hit “XHTML Strict” titles and wonder if they must rewrite every page. They do not — HTML5 is the mainstream teaching and browser target. Still, knowing the old strictness explains why tutorials demand lowercase tags, quoted attributes, and <br />. After SSE’s “server pushes events,” this lesson’s split is different: markup rules and history, not realtime APIs. You need the idea of XML-flavored HTML, a short habit table, and two tiny contrasts — enough to read legacy material without building an XML toolchain.

Direct answer

1) XHTML = HTML formulated as XML (stricter syntax expectations).
2) Classic habits: lowercase element/attribute names, quoted attribute values, explicit empty elements (<br />, <img … />).
3) Modern default: HTML5 with <!DOCTYPE html> — parsers are more forgiving.
4) Clean markup still matters for accessibility, maintainability, and tooling — HTML5 is not a license for broken trees.
5) For new projects in this course, use HTML5 patterns from earlier lessons.
6) Use this page to translate old XHTML advice into HTML5 practice — not to ship a pure XHTML MIME site unless you already know that path.

📊 HTML5 vs classic XHTML habits

Topic HTML5 (this course) XHTML-style strictness
Doctype <!DOCTYPE html> Older XHTML DOCTYPE lines
Empty elements <br> / <img> fine Often <br /> / <img … />
Attribute quotes Strongly recommended Required in XHTML
Element case Lowercase by convention Lowercase required in XHTML
Error recovery Forgiving HTML parsers XML rules were stricter
This course depth Required (daily practice) History + habits to recognize
Not this lesson Full CSS layout course XML schemas / MIME product design

Tiny empty-tag contrast

Same meaning, two writing styles. Browsers accept both in typical HTML5 pages; the slash form is the visual clue you are reading XHTML-era material.

Empty tag contrast HTML5 vs XHTML-looking

html
<!-- HTML5-friendly empty tags -->
<p>Line one<br>Line two</p>
<img src="photo.jpg" alt="Demo photo">

<!-- XHTML-looking empty-element form -->
<p>Line one<br />Line two</p>
<img src="photo.jpg" alt="Demo photo" />

Reading the contrast

  • <br> and <br /> both mean a line break in everyday HTML5 browsing
  • The trailing / was required empty-element syntax in XHTML-style XML writing
  • Quotes around src and alt are good HTML5 habit and were required in XHTML
  • Lowercase img / br matches both modern convention and classic XHTML rules
  • This is not SSE — no EventSource, no stream URL, no onmessage
  • Do not switch MIME types just because you typed <br />
  • Keep intros tiny: one contrast, one idea

Tiny well-formed mini page

A short document that follows habits both eras respect: doctype, charset, quoted attributes, closed elements. Stay on HTML5 doctype even when markup is tidy.

Tiny well-formed HTML5 mini page

html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Well-formed mini page</title>
</head>
<body>
<h1>Clean markup still helps</h1>
<p>Quoted attributes and closed tags keep the tree clear.</p>
<img src="photo.jpg" alt="A demo photo">
</body>
</html>

Reading the mini page

  • <!DOCTYPE html> marks HTML5, not an old XHTML doctype
  • lang, charset, and quoted attributes are durable good habits
  • Every opened non-void element is closed — XML-era discipline that still helps humans and tools
  • alt on the image is accessibility, not nostalgia
  • Still unrelated to SSE streams or Web Workers
  • If an old tutorial shows xmlns and XHTML 1.0 Strict doctype, map the habits here and keep HTML5 for new work
  • Next steps in learning are usually CSS/layout courses — not forcing XML MIME on production

Choosing HTML5, XHTML habits, or old tutorials

  • New page in this course: HTML5 doctype + clean habits from earlier lessons
  • Reading a 2005 “XHTML Strict” book: translate rules → lowercase, quotes, close tags; keep HTML5 doctype
  • Seeing <br /> in a snippet: recognize XHTML-era style; it can still appear inside HTML5 files
  • Need live server push updates: that was SSE, not XHTML
  • Need off-thread local compute: that was Web Workers
  • Building XML schemas or application/xhtml+xml products: beyond this intro/compare lesson

Practice — compare, keep HTML5, contrast eras

  1. Read the empty-tag contrast; say which form looks XHTML-era.
  2. Skim the habit table; note quotes and lowercase.
  3. Read the mini page; confirm <!DOCTYPE html> stays HTML5.
  4. Write one sentence: SSE streams server events; XHTML is markup history/strictness.
  5. Write one sentence: new beginner projects should target HTML5, not “XHTML Strict forever.”
  6. (Optional) Take one messy snippet and quote attributes + close tags without changing the doctype away from HTML5.
  7. Course note: this closes the HTML quality rewrite queue’s last session topic.

Easy mistakes

  • Forcing full XHTML MIME / XML parsing modes without understanding breakage risk
  • Treating HTML5’s forgiveness as permission for inaccessible or inconsistent markup
  • Mixing random XHTML-era and HTML5 idioms in one team style guide without agreement
  • Confusing this history lesson with SSE (no EventSource here)
  • Believing every modern site must ship as XHTML 1.1 Strict
  • Copying an old XHTML doctype into a new project “for quality”
  • Thinking quoted attributes are “only for XHTML” (they remain a strong HTML5 habit)

Summary

  • XHTML was HTML under stricter XML-style rules
  • HTML5 with <!DOCTYPE html> is the modern default in this course
  • Lowercase, quotes, and clear empty/closed tags still help
  • Translate old XHTML tutorials; do not treat them as the only legal future
  • SSE was live server push; this lesson is markup history
  • HTML rewrite queue for this course ends here — next learning track is typically CSS when that course is published

🧠 Test Your Knowledge

Ready to Start

Test Your Knowledge

Challenge yourself with this interactive quiz and see how well you understand the topic

❓
5
Questions
🎯
70%
To Pass
♾️
∞
Time
🔄
∞
Attempts

📝 Instructions

  • Read each question carefully
  • Select the best answer for each question
  • You can retake the quiz as many times as you want
  • Your progress will be shown at the top