erlug
[Top] [All Lists]

RE: [Erlug] Html - Questo sconosciuto

To: "'erlug@xxxxxxxxxxxxxx'" <erlug@xxxxxxxxxxxxxx>
Subject: RE: [Erlug] Html - Questo sconosciuto
From: Alessandro Forghieri <Alessandro.Forghieri@xxxxxxxxxx>
Date: Tue, 24 Sep 2002 11:09:24 +0200
Saluti.

<!xxx>
E' una dichiarazione SGML  *non* un commento...
ad esempio:

<!doctype html public "-//ietf//dtd html//en">

Che poi alcuni processori HTML ignorino la maggior parte delle dichiarazioni
non vuol dire che le due cose siano intercambiabili. 

A braccio, i commenti sono appunto quelli che cominciano con la sequenza
<!-- terminata dalla sequenza -->. (Il tuo problema e' un po' difficile da
inquadrare - ci vorrebbe un esempio). Il dettaglio che segue e' preso da
htmlhelp.com e alla fine confonde un po' le idee se non si capisce che:

<!                           <===questo inizia la dichiarazione

-- blah blah blah blah --     <===questo e' un commento

-- foo bar --                 <====un altro commento
>                             <====fine dichiarazione

Per cui il tag:

<!------> hello-->

Dichiara *due* commenti:

(i)  ----
(ii) --> hello--

(i) e' vuoto, (ii) contiene la sequenza di caratteri "> hello". Quasi tutti
i browser su questo esempio si sbagliano.

Questo e' un inutile spaccare il capello in 4 fino a che non si cercano di
annidare i commenti, o i commenti contengono la sequenza --, etc...

In generale, la regola semplice funziona.

Cheers,
alf

HTML comments

Since HTML is officially an SGML application, the comment syntax used in
HTML documents is actually the SGML comment syntax. Unfortunately this
syntax is a bit unclear at first. 

The definition of an SGML comment is basically as follows: 

A comment declaration starts with <!, followed by zero or more comments,
followed by >. A comment starts and ends with "--", and does not contain any
occurrence of "--". 

This means that the following are all legal SGML comments: 

<!-- Hello --> 
<!-- Hello -- -- Hello--> 
<!----> 
<!------ Hello --> 
<!> 

Note that an "empty" comment tag, with just "--" characters, should always
have a multiple of four "-" characters to be legal. (And yes, <!> is also a
legal comment - it's the empty comment). 

Not all HTML parsers get this right. For example, "<!------> hello-->" is a
legal comment, as you can verify with the rule above. It is a comment tag
with two comments; the first is empty and the second one contains "> hello".
If you try it in a browser, you will find that the text is displayed on
screen. 

There are two possible reasons for this: 

The browser sees the ">" character and thinks the comment ends there. 
The browser sees the "-->" text and thinks the comment ends there. 
There is also the problem with the "--" sequence. Some people have a habit
of using things like "<!-------------->" as separators in their source.
Unfortunately, in most cases, the number of "-" characters is not a multiple
of four. This means that a browser who tries to get it right will actually
get it wrong here and actually hide the rest of the document. 
For this reason, use the following simple rule to compose valid and accepted
comments: 

An HTML comment begins with "<!--", ends with "-->" and does not contain
"--" or ">" anywhere in the comment. 





-----Original Message-----
From: Hiro Kunimi [mailto:hiro@xxxxxxxxxxxx]
Sent: Monday, September 23, 2002 11:31 PM
To: Erlug
Subject: [Erlug] Html - Questo sconosciuto


Sapete spiegarmi la differenza tra il tag <!-- xxx> e il tag <! xxx>? Io
sapevo che qualsiasi tag iniziasse per <! era considerato un commento... A
maggior ragione <!-- a casa mia era un commento. Mi sono perso qualcosa?
Ora, come mai Netscape 7 / Mozilla 1 mi fa vedere ciò che c'e' dopo <!--
mentre exploder nasconde tutto?
------
hiro@xxxxxxxxxxxx - kamuro@xxxxxxxxxxxx
Webmaster of www.clubs2m3.net - Anime & manga portal with more than 10.000
images!!!
------

<Prev in Thread] Current Thread [Next in Thread>