</> Code Corner

HTML · HTML Tutorial · Lesson 39

HTML vs. XHTML

The stricter, XML-based version of HTML.

XHTML stands for EXtensible HyperText Markup Language. It is a stricter, XML-based version of HTML.

The Most Important Differences

  • <!DOCTYPE> is mandatory
  • The xmlns attribute in <html> is mandatory
  • Elements must always be properly nested and closed
  • Elements and attribute names must be in lowercase
  • Attribute values must always be quoted and cannot be minimized
  • Empty elements must be closed: <br />

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Title of document</title></head>
<body>
  <p>A line break:<br /></p>
  <input type="checkbox" name="vehicle" value="car" checked="checked" />
</body>
</html>

Keep reading “HTML vs. XHTML”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋