Kanbritech Learn logo
HTML HTML Tutorial 45h track

HTML vs. XHTML

Explain whether <br /> in a text/html document makes it XHTML.

Understand the topic

HTML and XHTML have different parsing rules. Normal text/html documents use the HTML parser, which can recover from many syntax errors. XHTML uses XML syntax and, when served as XML, requires well-formed markup with stricter handling of errors. Writing a slash on an HTML void element does not switch the document to XML parsing.

Worked example

<!-- HTML syntax -->
<input type="text" required>
<br>

<!-- XML-style syntax -->
<input type="text" required="required" />
<br />

The response media type determines how the browser parses a document. Modern HTML authoring normally uses text/html with the short doctype.

Practice

Explain whether <br /> in a text/html document makes it XHTML.

Show a suggested answer
No. The document is still parsed as HTML. XML-style spelling alone does not change its media type or parser.

Common mistake

Do not rely on HTML error recovery when serving an actual XML document. A well-formedness error can prevent rendering.

HTML documentation

Try Coding

Result