Re: Error on -- in a comment

vincent RABOT wrote:

> If I have this :
> <!--[if lte IE 6]>
> <div id="A1949 class="boite boite_F " style="width:34.5mm;
> height:46.5mm; left:158.25mm; top:324.25mm;" title="NGUYEN--RABOT ; °
> 2001">

It is invalid because the second "--" terminates the comment. The 
comment syntax in SGML and XML, hence in (X)HTML too, is relatively 
complicated. The simple rule is that you should use <!--comment--> where 
the comment does not contain any consecutive hyphens, "--". If it does, 
you'll meet the dark side of comments, so to say; it's pretty well 
explained at http://www.htmlhelp.com/reference/wilbur/misc/comment.html

This implies that data starting from "RABOT" is taken as appearing 
outside a comment but inside a comment declaration:

> 1. Line 1638, Column 124: invalid comment declaration: found name
> start character outside comment but inside comment declaration.

You seem to have located this problem well, since you then say that if 
you replace the second "--" by "-/-", the validator does not report an 
error. But of course the document content is then not what you want.

However, you can e.g. replace either of the hyphens by its character 
reference "&#45;" to avoid the problem, i.e. write the title attribute 
as
title="NGUYEN-&#45;RABOT ; ° 2001"
(though you probably have something else in place of "°" - the character 
encoding probably got distorted). Alternatively, if "--" is really 
supposed to present a dash, you might replace it by "&ndash;" or 
"&mdash;" to get the proper character, en dash or em dash (though 
support to them in attribute values is not quite universal).

Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/ 

Received on Thursday, 3 April 2008 13:33:45 UTC