n). Here's the highlights.
The first tag in a XHTML document must be <!DOCTYPE>. This tag informs the reader which definition to use
in describing the XHTML document. XHTML uses DTD modules to translate tags. In selecting among the three
DTDs follow these rules.
When writing pure XHTML use the strict DTD:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
When writing for the most HTML compatibility use the transitional DTD :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
When using frames use the frameset DTD:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "DTD/xhtml1-frameset.dtd">
The transitional DTD will be used for most pages.
The second tag in a XHTML document must be <html> and the xmlns attribute is mandatory.
The <title> tag is mandatory in a XHTML document.
Form tags must have an action attribute. For example, <form action="test.htm"></form>
Style tags such as <font> and <center> have been removed! Use style sheets for formatting.
Data (which in a HTML page would be text) must be enclosed within a set of valid tags. A partial list of
valid tags to enclose free standing data (text) includes "p", "h1" "div", "pre".
The first example is wrong because the data (text) is not enclosed within a defined tag set
<body>
HI, this is Wrong.
<br/>
<a href="http://validator.w3.org/check/referrer">validate</a>
</body>
This is the correct way to include data using the div tag.
<body>
<div>
HI, this is Right.
<br/>
<a href="http://validator.w3.org/check/referrer">validate</a>
</div>
</body>
Every <img> tag must have an alt attribute.
Every <style> tag must have a type attribute.
No stand-alone attributes (also known as minimized attributes) are allowed. For example, <option selected>
is no longer valid. Instead, it will look like <option selected="selected">.
"Inline" tags cannot contain "block-level" tags. For example, an anchor tag can't enclose a <table>
Scripting elements pose a problem for XHTML compatibility. The XML parser will parse the script as a XML
document unless you enclose your script in a CDATA block. Therefore, a JavaScript element would now look
like:
<script type="text/javascript">
<![CDATA[ alert("hello"); ]]>
</script>
This causes a hassle for all the current browsers as they will not like the CDATA block. For now, the only
solution is to call the JavaScript from an external file. For example:
<script language="JavaScript" type="text/javascript" src="main.js"></script>
For the server-side programmer this is a problem when you modify the JavaScript dynamically. Using a
separate file source for your JavaScript prevents you from being able to dynamically change your
JavaScript. This is because the JavaScript is being included on the client side so the server side won't
be able to touch it now. When modifying JavaScript using ASP, JSP or PHP scripting, use the standard HTML
method of script declaration. This is the one place where making JSP or ASP 100% compatible with XHTML
will be most problematic. Remember, however, the goal is not to be 100% compatible with XHTML, but to
begin incorporating XHTML where feasible, allowing a quick and easy transition when the time comes. When
that time arrives, new compatible browsers should be available and you'll be set to make the jump to 100%
compatibility.
Conclusion
In this article we've explored some advantages of XHTML and how to start using it right now with very
little hassle. XHTML is far more than a replacement for HTML. Thinking of it as HTML 5.0 unnecessarily
limits its power and the possibilities it will introduce. XHTML is meant to be expanded by the user
community. It creates XML documents which contain, define and manipulate data, going far beyond the
capabilities of HTML-based documents. It makes XML easy to use. To fully realize the potential XHTML
presents will require a new way of thinking about future applications. It creates fresh possibilities.
XHTML really is a new thing (not merely an upgrade) and the challenge ahead of us is to experiment and
discover where it can take us.
The first tag in a XHTML document must be <!DOCTYPE>. This tag informs the reader which definition to use
in describing the XHTML document. XHTML uses DTD modules to translate tags. In selecting among the three
DTDs follow these rules.
When writing pure XHTML use the strict DTD:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
When writing for the most HTML compatibility use the transitional DTD :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
When using frames use the frameset DTD:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "DTD/xhtml1-frameset.dtd">
The transitional DTD will be used for most pages.
The second tag in a XHTML document must be <html> and the xmlns attribute is mandatory.
The <title> tag is mandatory in a XHTML document.
Form tags must have an action attribute. For example, <form action="test.htm"></form>
Style tags such as <font> and <center> have been removed! Use style sheets for formatting.
Data (which in a HTML page would be text) must be enclosed within a set of valid tags. A partial list of
valid tags to enclose free standing data (text) includes "p", "h1" "div", "pre".
The first example is wrong because the data (text) is not enclosed within a defined tag set
<body>
HI, this is Wrong.
<br/>
<a href="http://validator.w3.org/check/referrer">validate</a>
</body>
This is the correct way to include data using the div tag.
<body>
<div>
HI, this is Right.
<br/>
<a href="http://validator.w3.org/check/referrer">validate</a>
</div>
</body>
Every <img> tag must have an alt attribute.
Every <style> tag must have a type attribute.
No stand-alone attributes (also known as minimized attributes) are allowed. For example, <option selected>
is no longer valid. Instead, it will look like <option selected="selected">.
"Inline" tags cannot contain "block-level" tags. For example, an anchor tag can't enclose a <table>
Scripting elements pose a problem for XHTML compatibility. The XML parser will parse the script as a XML
document unless you enclose your script in a CDATA block. Therefore, a JavaScript element would now look
like:
<script type="text/javascript">
<![CDATA[ alert("hello"); ]]>
</script>
This causes a hassle for all the current browsers as they will not like the CDATA block. For now, the only
solution is to call the JavaScript from an external file. For example:
<script language="JavaScript" type="text/javascript" src="main.js"></script>
For the server-side programmer this is a problem when you modify the JavaScript dynamically. Using a
separate file source for your JavaScript prevents you from being able to dynamically change your
JavaScript. This is because the JavaScript is being included on the client side so the server side won't
be able to touch it now. When modifying JavaScript using ASP, JSP or PHP scripting, use the standard HTML
method of script declaration. This is the one place where making JSP or ASP 100% compatible with XHTML
will be most problematic. Remember, however, the goal is not to be 100% compatible with XHTML, but to
begin incorporating XHTML where feasible, allowing a quick and easy transition when the time comes. When
that time arrives, new compatible browsers should be available and you'll be set to make the jump to 100%
compatibility.
Conclusion
In this article we've explored some advantages of XHTML and how to start using it right now with very
little hassle. XHTML is far more than a replacement for HTML. Thinking of it as HTML 5.0 unnecessarily
limits its power and the possibilities it will introduce. XHTML is meant to be expanded by the user
community. It creates XML documents which contain, define and manipulate data, going far beyond the
capabilities of HTML-based documents. It makes XML easy to use. To fully realize the potential XHTML
presents will require a new way of thinking about future applications. It creates fresh possibilities.
XHTML really is a new thing (not merely an upgrade) and the challenge ahead of us is to experiment and
discover where it can take us.