HTML5 vs XML: Syntax Rules, Void Elements & Parsing Models
- • HTML5 and XML share common markup roots but adhere to fundamentally different parsing specifications:
- • XML (Extensible Markup Language): Strict, well-formed syntax is mandatory. Every opening tag must have a matching closing tag or be explicitly self-closed (<tag />). Attributes must always be quoted, and tag names are strictly case-sensitive.
- • HTML5: Governed by the WHATWG living standard. HTML5 is forgiving and supports void elements (such as <img>, <br>, <hr>, <input>, <meta>) that cannot have closing tags or self-closing slashes. It also allows unquoted attribute values and boolean attributes (e.g., disabled, required).
<!-- Valid HTML5 Void Element (No Closing Tag Required) -->
<input type="text" name="username" required disabled>
<!-- Equivalent Strict XML / XHTML Syntax -->
<input type="text" name="username" required="required" disabled="disabled" />