- From: Rui del-Negro <w3validator@dvd-hq.info>
- Date: Thu, 25 Jan 2007 16:31:13 -0000
- To: bkml <atoz0to9@fastmail.fm>
- Cc: www-validator@w3.org
> I have the following comment in a page that is perfectly valid HTML 4.01 > Strict ... > > <!---------------------------------------------------------------------- > ---------------------------------------- > H E A D E R for site logo, title, tag line and language menu > > ------------------------------------------------------------------------ > --------------------------------------> > > If line 1 of the comment exceeds 110 dashes, the validator reports the > 111th dash as an error. > > What's weirder than that is the fact that the closing line (line 3) has > to have exactly the same number of dashes as the opening line or else > the validator reports an error in whichever line follows. > > This doesn't make any sense at all. Can somebody please fix the > validator so that it will not read any meaning into comments, thanks. You're right that it doesn't make any sense at all (or rather, it's impractical and unintuitive), but the validator is working fine. The real problem is the way SGML (and, as a result, HTML) defines comments. And unfortuntely this wasn't changed in XML, so the same rule applies: Within a <! ... > block, "--" starts a comment if none is started, and ends a comment if one has been started. Apparently this is a great "feature". :P So when you put 8 dashes, for example, you've actually started and ended two (empty) comments. If you use 6 dashes, you've started and ended one comment, and then started another one. If you use five dashes you've started and ended a comment, and then added another dash inside the comment declaration (but outside a comment) - no idea what that does, probably gives you an error, too. If you have three dashes, then a space, then two dashes, then everything is fine because the third dash is part of the comment contents. Really intuitive, eh? So, to sum it all up in a (simple?) rule: _before_ your comment text, you always need to have N*4+2[+1] dashes, where N can be zero, and the +1 is optional (ex., 2, 3, 6, 7, 10, 11, 14, 15, etc.). After the comment you need to have N*4+2 dashes. Instead of counting dashes, it's probably easier to use a different character, or put spaces between all except the first two and last two dashes. In other words, use this: <!-- ~~~~~~~~ --> Or this: <!-- - - - - - - - - - - - - --> For example, and it should work fine. In general, avoid having two dashes in a row, except at the start and end of the comment declaration, and you should be fine. RMN ~~~
Received on Thursday, 25 January 2007 16:31:33 UTC