XHTML, short for EXtensible HyperText Markup Language, represents a more stringent, XML-oriented iteration of HTML. It’s essentially HTML conceptualized as an XML application and garners support from all major browsers.
XML serves as a markup language requiring all documents to be correctly marked up, or “well-formed.”
XHTML emerged with the aim of enhancing HTML’s extensibility and adaptability to collaborate with other data formats, notably XML.
Moreover, while browsers typically overlook errors in HTML pages and attempt to display websites despite markup flaws, XHTML adopts a significantly stricter approach to error handling.
The following guidelines apply:
In XHTML, elements must always be correctly nested within one another, as shown:
<b><i>Some text</i></b> |
<b><i>Some text</b></i> |
In XHTML, elements must always be properly closed, as demonstrated:
<p>This is a paragraph</p> <p>This is another paragraph</p> |
<p>This is a paragraph <p>This is another paragraph |
In XHTML, empty elements must always be closed, as depicted:
A break: <br /> A horizontal rule: <hr /> An image: <img src=”happy.gif” alt=”Happy face” /> |
A break: <br> A horizontal rule: <hr> An image: <img src=”happy.gif” alt=”Happy face”> |
In XHTML, element names must always be in lowercase, as illustrated:
<body> <p>This is a paragraph</p> </body> |
<BODY> <P>This is a paragraph</P> </BODY> |
In XHTML, attribute names must always be in lowercase, as exemplified:
<a href=”https://www.code7schools.com/html/”>Visit our HTML tutorial</a> |
<a HREF=”https://www.code7schools.com/html/”>Visit our HTML tutorial</a> |
In XHTML, attribute values must always be enclosed in quotes, as shown:
<a href=”https://www.code7schools.com/html/”>Visit our HTML tutorial</a> |
<a href=https://www.code7schools.com/html/>Visit our HTML tutorial</a> |
In XHTML, attribute minimization is not permitted:
<input type=”checkbox” name=”vehicle” value=”car” checked=”checked” /> <input type=”text” name=”lastname” disabled=”disabled” /> |
<input type=”checkbox” name=”vehicle” value=”car” checked /> <input type=”text” name=”lastname” disabled /> |