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 |
<table WIDTH="100%">
|
<table width="100%">
|
Attribute Values Must Be Quoted
| Wrong |
Correct |
<table width=100%>
|
<table width="100%">
|
Attribute Minimization Is Forbidden
| Wrong |
Correct |
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>
|
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />
<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.
A man is washing his car with his son.
The son asks, “Dad, can’t you just use a sponge?”
|