0

Explain the difference between HTML and XHTML ?

author
pranav m
medium
0
34

Answer
  • HTML (HyperText Markup Language)
    • More forgiving: browsers auto-correct many mistakes.
    • Tags/attributes not case-sensitive (<P> = <p>).
    • Not all elements require closing tags (<br>, <img>).
    • Attribute values can sometimes be unquoted.
    • MIME type: text/html.
  • XHTML (Extensible HyperText Markup Language)
    • Based on XML → must be well-formed.
    • Strict rules:
      • Tags and attributes in lowercase.
      • Must close all elements (<br /> not <br>).
      • Attributes must have quoted values.
      • Proper nesting required.
    • MIME type: application/xhtml+xml.

Example HTML vs XHTML

<!-- HTML -->
<p><img src="img.png" width=200>

<!-- XHTML -->
<p><img src="img.png" width="200" /></p>

Click to Reveal Answer

Tap anywhere to see the solution

Revealed

Comments0