Web Design HTML Editor

HTML vs XHTML

Although XHTML and HTML are very similar since they use the same tags and attributes, XHTML contains many rules that you must follow to ensure compatibility with all browsers and devices. The following explains how to write an XHTML web page so that it complies with the XHTML standards;

Tags must be written in lowercase

All tags in XHTML including tag name and attributes must be written in lowercase. So the following code is illegal in XHTML;

<B>...bold text...</B>

And must be replaced with;

<b>...bold text...</b>

All tags must be closed

XHTML requires that all tags use their appropriate ending tags. If a tag does not require an ending tag a '/' must be inserted before the closing >. So to insert an image into an XHTML document, the image tag must be written like so;

<img src="images/picture.jpg" />

It is recommend to insert a space before the '/>' to ensure compatibility with older browsers

All attributes require a value

All tags in XHTML require a value. The following code can not be used in XHTML;

<input checked>

It must be written as;

<input checked="checked" />

Attribute values must be quoted

XHTML requires that all attribute values be quoted. The following code;

<img width=100>

Must be replaced with;

<img width="100" />

Name attribute is replaced by ID

Some HTML tags that use the name attribute must be replaced with the ID attribute. To help ensure compatibility with older browsers you can use both the name attribute and the ID attribute in the same tag.

Documents must be properly nested

XHTML requires that your documents tags be properly nested. In HTML the following code is legal and will show up correctly in most web browsers;

<B><U>Bold and underlined text</B></U>

However, it is illegal in XHTML and must be written in this way;

<B><U>Bold and underlined text</U></B>

Proper DTD must be used

ALL XHTML documents require the proper DOCTYPE declaration. The html head and body tags must be used. The following is the most basic XHTML document;

	<!DOCTYPE appropriate doctype>
	<html>
	<head><title>Web Page Title</title>
	</head>
	<body>
	....xhtml content goes here....
	</body>
	</html>
Previous | Top | Next


Have Any Questions? Post them on our FREE discussion forum at http://www.ragesw.com/forums/
Copyright 1999-2005 Rage Software. All rights reserved world wide
Back to Index | More About WebDesign | FREE WebDesign Add-ons

Designed With WebDesign