Slide 3.7: Differences between XHTML and HTML (cont.)
Slide 3.9: XHTML syntax (cont.)
Home

XHTML Syntax


Writing XHTML demands a clean HTML syntax:
  • Attribute names must be in lower case.
  • Attribute values must be quoted.
  • Attribute minimization is forbidden.
  • The id attribute replaces the name attribute.
  • The XHTML DTD defines mandatory elements.

Attribute Names Must Be in Lower Case

Wrong Correct
1<table WIDTH="100%">
1<table width="100%">

Attribute Values Must Be Quoted

Wrong Correct
1<table width=100%>
1<table width="100%">

Attribute Minimization Is Forbidden

Wrong Correct
1<input checked>
2<input readonly>
3<input disabled>
4<option selected>
5<frame noresize>
1<input checked="checked" />
2<input readonly="readonly" />
3<input disabled="disabled" />
4<option selected="selected" />
5<frame noresize="noresize" />

Below are minimized attributes and how they should be in XHTML:

HTML XHTML HTML XHTML HTML 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"


Demonstration
The following demonstration shows how the script of HTML is displayed on the Web.