La validation d'un document XHTML
Maintenant que votre page XHTML est créée, il faut encore la valider.

Pourquoi valider la page?

Parce que si une page n'est pas validée, elle est mal interprétée et tous vos efforts n'auront servi à rien.
Comment faire pour valider une page?
Rendez-vous sur le validateur en ligne du W3C. Envoyez l'URL de votre page ou bien téléchargez-la depuis votre ordinateur et cliquez sur "vérifier". Vous verrez alors la liste de toutes les erreurs s'afficher. Une fois que celles-ci seront corrigées (bon courage), vous pourrez, ô joie suprême, afficher le logo du W3C sur votre page pour dire que celle-ci est conforme aux normes du XHTML. Voici un exemple. Je crée cette page en laissant volontairement quelques erreurs:

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml xml.lang="fr" lang="fr">
<meta NAME="description" content="Page de validation">
</head><body>
<img SRC="image.jpg" width=120 height=180 />
<br><br>
Bonjour & au revoir
</body>
</html>

Voici ce que le validateur indique:

This page is not Valid (no Doctype found)!
Below are the results of attempting to parse this document with an SGML parser.
1. Error Line 3 column 51: value of fixed attribute "XMLNS" not equal to default.
<html xmlns="http://www.w3.org/1999/xhtml xml.lang="fr" lang="fr">

2. Error Line 3 column 54: an attribute value literal can occur in an attribute specification list only after a VI delimiter.
<tml xmlns="http://www.w3.org/1999/xhtml xml.lang="fr" lang="fr">
Have you forgotten the "equal" sign marking the separation between the attribute and its declared value? Typical syntax is attribute="value".

3. Error Line 3 column 56: character data is not allowed here.
<html xmlns="http://www.w3.org/1999/xhtml xml.lang="fr" lang="fr">
You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>) or forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes).

4. Error Line 4 column 53: start tag for "HEAD" omitted, but its declaration does not permit this.
<meta NAME="description" content="Page de validation">

5. Error Line 5 column 6: end tag for "HEAD" which is not finished.
</head><body>
Most likely, You nested tags and closed them in the wrong order. For example <p><em>...</p> is not acceptable, as <em> must be closed before <p>. Acceptable nesting is: <p><em>...</em></p>
Another possibility is that you used an element which requires a child element that you did not include. Hence the parent element is "not finished", not complete. For instance, <head> generally requires a <title>, lists (ul, ol, dl) require list items (li, or dt, dd), and so on.

6. Error Line 6 column 42: required attribute "ALT" not specified.
<img SRC="image.jpg" width=120 height=180 />
The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.

Vous corrigez alors la page comme ceci:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head><title>Ma page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Page de validation" />
</head><body>
<img src="image.jpg" alt="image introuvable" width="120" height="180" />
<br />
Bonjour &amp;amp; au revoir
</body>
</html>

Nous avons alors la joie (immense) de voir s'afficher ceci:
image introuvable
Vous pourrez alors afficher le petit logo du W3C sur votre page.

Voilà, vous êtes maintenant capable de créer une page XHTML tout à fait valide.
   

Creative Commons License
Sauf mention contraire, le contenu de cette page est sous licence Creative Commons
Page générée en 0.3522 secondes.
Retour en haut de la page
Imprimer cette page