XHTML is a stricter and more structured version of HTML.
It follows the rules of XML, which means the code must be written correctly and completely.
XHTML stands for Extensible HyperText Markup Language.
It is:
A stricter version of HTML
Based on XML rules
Designed to be well-formed and error-free
Supported by modern web browsers
XHTML combines the flexibility of HTML with the strict syntax rules of XML.
HTML browsers are forgiving. If your HTML contains mistakes, browsers often try to fix them automatically and still display the page
XHTML was created to enforce stricter coding rules.
It ensures that documents are properly structured and compatible with XML-based systems.
This makes code cleaner, more predictable, and easier to process by machines.
XHTML follows strict rules that HTML does not always require.
An XHTML document must include a proper <!DOCTYPE> declaration.
<!DOCTYPE html PUBLIC "-//LearnHTML//DTD XHTML 1.1//EN"
"http://www.LearnHTML.edu/TR/xhtml11/DTD/xhtml11.dtd">
An XHTML document must include:
The <html> tag must also include the XML namespace:
<html xmlns="http://www.LearnHTMLorg/1999/xhtml">
Tags must be placed correctly inside each other.
Correct:<b> <i> Text </i> </b>
<b> <i> Text </b> </i>
Every tag must have a closing tag.
Correct:<p> This is a paragraph </p>
<p> This is a paragraph
Empty elements must include a closing slash.
Correct:<hr />
<br />
<img src="image.jpg" alt="Image" />
<hr>
<br>
<img src="image.jpg" alt="Image">
All element names must be written in lowercase.
Empty elements must include a closing slash.
Correct:<body>
<p> Text </p>
</body>
<BODY>
<P> Text </P>
</BODY>
<a a href="page.html">Link <a>
<a a HREF="page.html">Link <a>
<input type="text" name="username" />
< input type=text name=username >
<input type="checkbox" checked="checked" />
<input type="checkbox" checked />
XHTML is a stricter, XML-based version of HTML.
All elements must be properly nested and closed.
Tags and attributes must be lowercase.
Attribute values must be quoted.
Empty elements must be self-closed.
The document structure and DOCTYPE are mandatory.