|
XHTML
XHTML stands for eXtensible Hyper-Text Markup Language. Extensible in that new tags can be added without changing the standards. XHTML documents are HTML documents that follow XML coding standards. XHTML files are well-formed XML documents.
The following are the basic guidelines to creating XHTML documents:
- XML Line - The first line
of an XHTML document is the XML Line:
<?xml version="1.0"?>
- Document Type Definition - This basically states which rules you are following. Examples:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"DTD/xhtml1-frameset.dtd">
- Namespace - Namespaces allow XML elements to have universal names. For instance, by
identifying the XHTML document with the XHTML namespace, XML readers will be
able to definitively determine that this is an XHTML document and should be
interpreted as such. Example:
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
- The HEAD - The HEAD section is mandatory in XHTML.
- HTML Tags - HTML Tags must be lowercase, and they all must either have close tags, or use the / at the end. Examples:
<hr> is acceptable HTML whereas <hr /> is acceptable XHTML and works just fine with any browser.
<p> is acceptable HTML whereas either <p /> or <p></p> is acceptable XHTML.
- Nested Tags - HTML tags must be nested properly.
<p><b>Some Text</p></b> - is not acceptable XHTML.
<p><b>SomeText</b></p> - is acceptable XHTML.
- HTML Attributes - HTML tag attributes (or properties) must be lowercase and be quoted.
<table cellpadding=5 cellspacing=5 cols=5> is not acceptable XHTML, but is acceptable HTML.
<table cellpadding="5" cellspacing="5" cols="5"> is acceptable XHTML AND is acceptable HTML.
Also, all attributes must have a value.
<img ISMAP src= "image.gif"> is not acceptable XHTML, but is acceptable HTML.
<img ismap="ismap" src= "image.gif"> is acceptable XHTML AND is acceptable HTML.
- Inline & Block Elements - Inline elements cannot contain block elements:
Inline elements (like <font>, <input>, <br>, <select>, and <textarea>) cannot contain block elements (like <table> <p>, <h1>, <div>, <ul>, and <ol>).
This is invalid:
<font face="Arial" size="2">
<table border="0">
<tr><td>Hello!</td></tr>
</table>
</font>
Whereas this is valid:
<table border="0">
<tr><td><font face="Arial" size="2">Hello!</font></td></tr>
</table>
|