TonyJollans
Programmer
Hi All,
Not my normal forum so I hope I've chosen the right one. I'm not quite a newbie but I'm not very experienced in this and am stumped. Any explanations would be gratefully received.
I've been trying to be a good little boy and, apart from what I'm told is my own inimitable style, trying to code up web pages 'properly'. All appears to work well in IE but in Netscape 7.0 I have been getting odd results which I have managed to pin down to be because of my comments.
Firstly, my page looks like this - the doctype and the start of the body section and the comment is reproduced EXACTLY, the rest just shows the general structure:
Now, when I display this in Netscape (7.0) I see nothing. The fact that it is nothing rather than a partial something does not appear to be significant, merely a consequence of the placement of comments. When I remove the URL from the DOCTYPE, my page displays as I intended, so I have a fix (of sorts) but I want to be able to avoid hitting the same problem over and over again.
I have tried to pin down the problem and found the following:
This works:
The page displays Test
------------------------------------------------------------------------------------------------------------
This (with extra minus signs) doesn't:
The page displays ---- --> Test
------------------------------------------------------------------------------------------------------------
But this (without the URL) does:
The page displays Test
------------------------------------------------------------------------------------------------------------
Much the same happens with the comment after the text, so this fails:
.. displaying Test ---- -->
-----------------------------------------------------------------------------------------------------------
Comments before and after the text seem to produce even more dramatic results (such as I originally had):
.. displays nothing
Finally, my understanding of comments is as follows:
The DOCTYPE statement at the start of the page is actually SGML.
The URI points to a formal declaration of the version of the HTML standard to which the document is written.
HTML does not have a comment construct of its own and (in theory) borrows the SGML one.
SGML statements begin with <! and end with >.
SGML comments within an SGML statement are delimited by -- before and after.
The HTML interpretation of this SGML construct is for comments to be delimited by <!-- and -->.
Comments in HTML cannot be nested.
What have I misunderstood?
Thanks In Advance,
Tony
Not my normal forum so I hope I've chosen the right one. I'm not quite a newbie but I'm not very experienced in this and am stumped. Any explanations would be gratefully received.
I've been trying to be a good little boy and, apart from what I'm told is my own inimitable style, trying to code up web pages 'properly'. All appears to work well in IE but in Netscape 7.0 I have been getting odd results which I have managed to pin down to be because of my comments.
Firstly, my page looks like this - the doctype and the start of the body section and the comment is reproduced EXACTLY, the rest just shows the general structure:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html401/loose.dtd">[/URL]
<HTML>
<HEAD>
<TITLE> ... </TITLE>
<META ...>
<SCRIPT Language = "JavaScript" Type = "Text/JavaScript">
<!--
Code:
(some javascript routines)
Code:
// -->
</SCRIPT>
<STYLE Type = "Text/CSS">
<!--
Code:
(some style definitions)
Code:
-->
</STYLE>
</HEAD>
<BODY BgColor="#000000">
<!--------------------------- Page content starts here ---------------------------->
<center>
<img ....>
Code:
(rest of page content including some more comments like the one above)
Code:
</Body>
</HTML>
Now, when I display this in Netscape (7.0) I see nothing. The fact that it is nothing rather than a partial something does not appear to be significant, merely a consequence of the placement of comments. When I remove the URL from the DOCTYPE, my page displays as I intended, so I have a fix (of sorts) but I want to be able to avoid hitting the same problem over and over again.
I have tried to pin down the problem and found the following:
This works:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html401/loose.dtd">[/URL]
<HTML>
<BODY>
<!-- -->
Test
</BODY>
</HTML>
The page displays Test
------------------------------------------------------------------------------------------------------------
This (with extra minus signs) doesn't:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html401/loose.dtd">[/URL]
<HTML>
<BODY>
<!---- -->
Test
</BODY>
</HTML>
The page displays ---- --> Test
------------------------------------------------------------------------------------------------------------
But this (without the URL) does:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<BODY>
<!---- -->
Test
</BODY>
</HTML>
The page displays Test
------------------------------------------------------------------------------------------------------------
Much the same happens with the comment after the text, so this fails:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html401/loose.dtd">[/URL]
<HTML>
<BODY>
Test
<!---- -->
</BODY>
</HTML>
.. displaying Test ---- -->
-----------------------------------------------------------------------------------------------------------
Comments before and after the text seem to produce even more dramatic results (such as I originally had):
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html401/loose.dtd">[/URL]
<HTML>
<BODY>
<!--- ----->
Test
<!-- ---->
</BODY>
</HTML>
.. displays nothing
Finally, my understanding of comments is as follows:
The DOCTYPE statement at the start of the page is actually SGML.
The URI points to a formal declaration of the version of the HTML standard to which the document is written.
HTML does not have a comment construct of its own and (in theory) borrows the SGML one.
SGML statements begin with <! and end with >.
SGML comments within an SGML statement are delimited by -- before and after.
The HTML interpretation of this SGML construct is for comments to be delimited by <!-- and -->.
Comments in HTML cannot be nested.
What have I misunderstood?
Thanks In Advance,
Tony