HOME
XHTML
XHTML
Introduction XHTML
Basic Tags XHTML Validation
XHTML with CSS
|
XHTML
XHTML is a cleaner version of HTML.
What Is XHTML?
|
* XHTML stands for EXtensible HyperText Markup Language
* XHTML is aimed to replace HTML
* XHTML is almost identical to HTML 4.01
* XHTML is a cleaner version of HTML
* XHTML is HTML defined as an XML application
* XHTML is a W3C Recommendation |
What I Should Know Before Starting
Before you continue you should have a basic understanding of the following:
* HTML and the basics of building web pages
If you want to Learn HTML first, read our HTML tutorial.
XHTML is a combination of HTML and XML (EXtensible Markup Language).
Why XHTML?
We can see now where many pages on the WWW contain "bad" HTML.
The following HTML code will work fine if you view it in a browser, even if it does not follow the HTML rules:
<html>
<head>
<title>This is page seems to be good but it is a bad HTML</title>
<body>
<h1>Bad HTML
</body>
XML is a markup language where everything has to be marked up correctly, which results in "well-formed" documents.
XML was designed to describe data and HTML was designed to display data.
Today we can see somany dfferent browser technologies, some browsers run Internet on computers, and some browsers run Internet on mobile phones and hand helds. The but these do not have the power to interpret a "bad" markup language.
Therefore - by combining HTML and XML, and their strengths, we got a markup language that is useful now and in the future - XHTML.
How To Get Ready For XHTML
XHTML is not very different from HTML 4.01
In addition, you should start NOW to write your HTML code in lowercase letters, and NEVER make the bad habit of skipping end tags like the .
notes |
* XHTML elements must be properly nested
* XHTML documents must be well-formed
* Tag names must be in lowercase
* All XHTML elements must be closed |
Elements Must Be Properly Nested
In HTML some elements can be improperly nested within each other like this:
<b><i>bold and italic</b></i><br>
In XHTML all elements must be properly nested within each other like this:
All XHTML elements must be nested within the root element.
Tag Names Must Be In Lower Case
This is because XHTML documents are XML applications. XML is case-sensitive. Tags like <br> and <BR> are interpreted as different tags.
This is wrong:
<BODY>
<h1>heading</h1>
</BODY>
This is correct:
<body>
<h1>heading</h1>
</body>
All XHTML Elements Must Be Closed
Non-empty elements must have an end 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
This is wrong:
This is a break <br>
Here comes a horizontal rule:<hr>
This is correct:
This is a break<br />
Here comes a horizontal rule:<hr />
|
|
|