91 11 989 175 4777 | Brampton, ON - Canada | New Delhi - India
XHTML tutorials
What Is XHTML?
- XHTML stands for EXtensible HyperText Markup Language
- XHTML is almost identical to HTML 4.01
- XHTML is a stricter and cleaner version of HTML
- XHTML is HTML defined as an XML application
- XHTML is a W3C Recommendation of January 2000.
- XHTML is supported by all major browsers.
Bad HTML
<html>
<head>
<title>This is bad HTML</title>
<body>
<h1>Bad HTML
<p>This is a paragraph
</body>
The Most Important Differences from HTML:
- XHTML elements must be properly nested
- XHTML elements must always be closed
- XHTML elements must be in lowercase
- XHTML documents must have one root element
XHTML Elements Must Be Properly Nested
In XHTML, all elements must be properly nested within each other, like this:
<b><i>This text is bold and italic</i></b>
XHTML Elements Must Always Be Closed
Non-empty elements must have a closing tag.
This is wrong:
<p>This is a paragraph
<p>This is another paragraph
This is correct:
<p>This is a paragraph</p>
<p>This is another paragraph</p>
Empty Elements Must Also Be Closed
Empty elements must also be closed.
This is wrong:
A break: <br>
A horizontal rule: <hr>
An image: <img src=”happy.gif” alt=”Happy face”>
This is correct:
A break: <br />
A horizontal rule: <hr />
An image: <img src=”happy.gif” alt=”Happy face” />
XHTML Elements Must Be In Lower Case
Tag names and attributes must be in lower case.
This is wrong:
<BODY>
<P>This is a paragraph</P>
</BODY>
This is correct:
<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. Child elements must be in pairs and correctly nested within their parent element.
The basic document structure is:
<html>
<head> … </head>
<body> … </body>
</html>
| This entry was posted by admin on September 14, 2011 at 7:08 am, and is filed under HTML tutorials, XHTML, XHTML Introduction, XHTML tutorials, html. Follow any responses to this post through RSS 2.0. You can skip to the end and leave a response. Pinging is currently not allowed. |
