|
|
XHTML TutorialThis XHTML tutorial demonstrates how to code web pages using XHTML. It assumes that you're already comfortable with HTML. XHTML is almost identical to HTML with only a handful of differences. XHTML is slightly more strict than HTML and requires a little more attention when coding. XHTML was developed by the W3C to help web developers make the transition from HTML to XML. So if you want to learn XML, XHTML is a good place to start. Here are the main things to remember when writing XHTML:
Here's a more detailed explanation of the above XHTML rules. DOCTYPEAll XHTML documents must have a DOCTYPE declaration. The document must include the usual html, head, title, and body elements. Example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
CaseAll XHTML tags should be lower case. (HTML tags on the other hand, can be upper or lower case). Wrong <A HREF="/xhtml/xhtml_tutorial.html">XHTML Tutorial</A> Right <a href="/xhtml/xhtml_tutorial.html">XHTML Tutorial</a> Closing tagsAll tags should have an opening tag and a closing tag. If it's a tag that doesn't have a closing tag (for example, the Wrong <img src="/pix/xhtml_tutorial.gif">Right <img src="/pix/xhtml_tutorial.gif" /> QuotesIn XHTML, all attribute values must be quoted. (In HTML on the other hand, you could get away without quoting attribute values). Wrong <img src="/pix/xhtml_tutorial.gif" width=250 height=50 border=0 /> Right <img src="/pix/xhtml_tutorial.gif" width="250" height="50" border="0" /> MinimizationMinimization is forbidden. You should explicitly state the attribute and the value. Wrong <option selected> Right <option selected="selected"> The id attributeThe id attribute replaces the name attribute. Instead of using Wrong <img src="/pix/xhtml_tutorial.gif" name="xhtml_tutorial">Right <img src="/pix/xhtml_tutorial.gif" id="xhtml_tutorial">Script tagThe Wrong
Right
NestingAll tags must be nested properly. Wrong <b><i> This text is bold and italic</b></i>Right <b><i> This text is bold and italic</i></b>Apart from these strict rules, you can code your XHTML pages just like you've been coding HTML pages. To learn more about coding HTML, check out the HTML tutorial. |
Need Website Content?
Get unique, quality digital content for your website.
|