Re: Comments in markup?

galactus@stack.urc.tue.nl (Arnoud "Galactus" Engelfriet) wrote:
>Yesterday I received an e-mail from someone who wanted to know more
>about HTML comments. I explained how they worked, and she then came
>up with the idea that you could embed comments in HTML tags then:
><A HREF="foo" -- A link to foo -->click here</A> would, according to
>her, be technically legal. Webtechs[0] didn't agree.
>
>When I tested this myself, I found out I couldn't use any SGML constructs
>other than DOCTYPES or comment elements in an HTML document when feeding
>it to the Webtechs validator. Is there a reason for this? Why would an
>SGML parser allow <!-- foobar --> but not <!ENTITY foobar ...>, both of
>which are valid SGML constructs?

	From the HTML 2.0 Specification:
	
  Comments
  
   To include comments in an HTML document, use a comment declaration. A
   comment declaration consists of `<!' followed by zero or more comments
                                   ^^^^
   followed by `>'. Each comment starts with `--' and includes all text
   up to and including the next occurrence of `--'. In a comment
   declaration, white space is allowed after each comment, but not before
   the first comment. The entire comment declaration is ignored. (10)
   
   For example:
   
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HEAD>
<TITLE>HTML Comment Example</TITLE>
<!-- Id: html-sgml.sgm,v 1.5 1995/05/26 21:29:50 connolly Exp  -->
<!-- another -- -- comment -->
<!>
</HEAD>
<BODY>
<p> <!- not a comment, just regular old data characters ->


	Without the "<!" *immediately* followed by "--", no comment
has been started.   Within that tag the "--" is an unknown attribute,
outside it would be just text (except that in SCRIPT it might be a
decrimenter for a variable 8-).

				Fote

=========================================================================
 Foteos Macrides            Worcester Foundation for Biomedical Research
 MACRIDES@SCI.WFBR.EDU         222 Maple Avenue, Shrewsbury, MA 01545
=========================================================================

Received on Monday, 29 July 1996 16:19:09 UTC