Differences between XHTML & HTML (Cont.)
XHTML Elements Must Always Be Closed
Non-empty elements must have an end tag.
| Wrong |
Correct |
<p>This is a paragraph
<p>This is another paragraph
|
<p>This is a paragraph</p>
<p>This is another paragraph</p>
|
Empty Elements Must also Be Closed
Empty elements must have an end tag or the start tag must end with
“/>.”
| Wrong |
Correct |
A break: <!-- Can't show. -->
A horizontal rule: <hr>
An image: <img src="happy.gif"
alt="Happy face">
|
A break: <!-- Can't show. -->
A horizontal rule: <hr />
An image: <img src="happy.gif"
alt="Happy face" />
|
XHTML Elements Must Be in Lower Case
| Wrong |
Correct |
<BODY>
<P>This is a paragraph</P>
</BODY>
|
<body>
<p>This is a paragraph</p>
</body>
|
XHTML Documents Must Have One Root Element
All XHTML elements must be nested within the
<html> root element.
All other elements can have sub elements.
Sub elements must be in pairs and nested within their parent element.
The basic document structure is
| Wrong |
Correct |
<BODY>
<P>This is a paragraph</P>
</BODY>
|
<html>
<head> ... </head>
<body> ... </body>
</html>
|
Demonstration
The following demonstration shows how the script of HTML is displayed on the Web.
|
Why can't you trust atoms? They make up everything.
|