W3C home > Mailing lists > Public > www-validator@w3.org > April 2008

Re: Error on -- in a comment

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Thu, 3 Apr 2008 16:33:06 +0300
Message-ID: <019b01c8958f$40949380$0500000a@DOCENDO>
To: "vincent RABOT" <vrabot@hotmail.com>, <www-validator@w3.org>

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 
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")
Received on Thursday, 3 April 2008 13:33:45 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:59:07 UTC