XHTML, A Better, Cleaner HTML

Category: HTML
Reviewed by: Chiggins   
Reviewed on: Dec 06 2007
» Discuss this topic (0 Posts)

Id Attribute replaces the name attribute

In HTML 4.01 the name attribute is defined in the a, applet, frame, iframe, img, and map tags. In XHTML, the name attribute is deprecated, and we use id.

This is wrong:
<img srcthingy.gif” namethingy” />
This is correct:
<img srcthingy.gif” idthingy” />
To compensate for older browsers, use both:
<img srcthingy.gif” idthingy” namethingy” />

The lang Attribute

Now in XHTML, the lang attribute is in almost every tag. It is used to show the language of the content of the tag. If we are to use the lang attribute, we must also use the xml:lang attribute.

<div langen” xml:langen”>Hello!</div>
<div langes” xml:langes”>Hola!</div>


The XHTML standard now defines three Document Type Definitions (DTD). They are Strict, Frameset, and the most common, Transitional. The DOCTYPE declaration must be at the start of every XHTML document, and because it is not a tag, it does not need an ending tag. Here is a minimal XHTML document with a Strict DTD.

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<title>Simple XHTML Page</title>
<p>This is a simple, minimal XHTML page.</p>

To define each DTD, use each of these:

Strict DTD
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
Frameset DTD
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN”
Traditional DTD
<!DOCTYPE html
PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”

Each DTD has its own used. Use Strict when you want very clean markup, free of clutter, and it works great with CSS. Transitional is used when you want to use of some deprecated HTML features, and browsers that don’t understand CSS. Lastly, Frameset is used when you want to have a page that has frames to partition the browsers window.