Friday, 2 March 2012

More XHTML Syntax Rules


More XHTML Syntax Rules

  • Attribute names must be in lower case
  • Attribute values must be quoted
  • Attribute minimization is forbidden
  • The XHTML DTD defines mandatory elements

Attribute Names Must Be In Lower Case

This is wrong:
<table WIDTH="100%">
This is correct:
<table width="100%">


Attribute Values Must Be Quoted

This is wrong:
<table width=100%>
This is correct:
<table width="100%">


Attribute Minimization Is Forbidden

This is wrong:
<input checked>
<input readonly>
<input disabled>
<option selected>
<frame noresize>
This is correct:
<input checked="checked" />
<input readonly="readonly" />
<input disabled="disabled" />
<option selected="selected" />


The Lang Attribute

The lang attribute applies to almost every XHTML element. It specifies the language of the content within an element.
If you use the lang attribute in an element, you must also add the xml:lang attribute, like this:
<div lang="it" xml:lang="it">Ciao bella!</div>


Mandatory XHTML Elements

An XHTML document must have a DOCTYPE declaration.
The html, head, title, and body elements must also be present.

No comments:

Post a Comment