Difference between HTML and XHTML |
|
XHTML is HTML, and is XML |
|
XHTML version 1.0 is almost exactly the same as HTML version 4.01. Both are current versions of HTML. The difference is that XHTML also conforms to the rules of XML. |
|
Differences |
|
Lower case element and attribute names
The difference between HTML and XHTML is that XHTML must also meet
the requirements of XML. The first important requirement is
that XML is case sensitive. XHTML meets this requirement
by making all element names and attribute names lower case.
In HTML you can use either upper case or lower case.
|
|
Close all container elements
All container elements must be closed in XHTML.
You can sometimes get away withour closing them in HTML.
|
|
Close empty elements with space slash
Some container elements do not have a closing tag.
In XHTML you must close them with a space slash.
The space slash is not required in HTML.
|
|
Do not mix up the closing tags
All element within a container elements must be closed before
the container is closed. You must do this in XHTML.
You should do this in HTML, but can sometimes get by with
tags in the wrong order
|
|
Every attribute must have a value
Every attribute you code must have a value in XHTML.
A few attribute values may be omitted HTML.
|
|
Every attribute value must be in quotes
Every attribute value must be in single quotes or double quotes in XHTML.
Sometimes quotes may be omitted HTML.
|
|
One each of html head title body are required in XHTML
One each of
This example is valid in both HTML and XHTML. <html> <head> <title> sample page </title> </head> <body> Hello. </body> </html> |
|
a DOCTYPE element is required in XHTMLA DOCTYPE element is required in XHTML. It is optional in HTML. |
|