XHTML, A Better, Cleaner HTML

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

There are some more “rules” to have a cleaner, XHTML friendly syntax.

  • Attribute values must be quoted
  • No attribute minimization
  • id attribute replace name attribute
  • The lang attribute
  • Mandatory elements

Quoted Attribute Values

All values for any attribute must be surrounded in quotes (“”).

<img srcthingy.gif” />
<table width95>

No Attribute Minimization

Some tags have attributes that in the past have been minimized in HTML. Now that is no longer acceptable with XHTML.

This is wrong:
<input checked />
<hr noshade />
<input disabled />
This is correct:
<input checkedchecked” />
<hr noshadenoshade” />
<input disableddisabled” />

Here is a list of the previously minimized attributes in HTML, and what they should be in XHTML.

compact compact="compact"
checked checked="checked"
declare declare="declare"
readonly readonly="readonly"
disabled disabled="disabled"
selected selected="selected"
defer defer="defer"
ismap ismap="ismap"
nohref nohref="nohref"
noshade noshade="noshade"
nowrap nowrap="nowrap"
multiple multiple="multiple"
noresize noresize="noresize"