Jump to content

Xhtml Comment <!-->


BashChelik

Recommended Posts

Hello fellow web designers!!!When writing comment like this:

<!--Comment goes here-->

Are those 2 slashes before and after the text "Comment goes here", part of the tag or part of the comment?I tried inserting comment without slashes and they remain hidden.

Best of luck,Mirko

Link to comment
Share on other sites

To do it properly, you have to put a space after the two hyphens and another space befor the closing tag:

<!--[space]Some text[space]-->

Otherwise, some browsers may not close the comment.

Link to comment
Share on other sites

Thank you for clarifying it to me.If u ask me, that is just complicating things that could be made simpler.I mean, why use the slashes and space if it could be clearer without it.It's not like <!Comment> is reserved or something, as i know.

Best of luck,Mirko

Link to comment
Share on other sites

The <! sequence is actually the markup declaration open delimiter, and only -- denotes the actual comment open delimiter. There are other markup declarations you can make, such as special character blocks like CDATA (<![CDATA[ ... ]]>).http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4.

Link to comment
Share on other sites

From the link Synook gave me:

White space is not permitted between the markup declaration open delimiter("<!") and the comment open delimiter ("--"), but is permitted between the comment close delimiter ("--") and the markup declaration close delimiter (">").
So ,is it OK if i put space between closing hyphens and closing angle brackets, like this?<!-- Comment -- >And between, are u sure u have to insert space after and before hyphens, because it is not mentioned anywhere?

Best of luck,Mirko

Link to comment
Share on other sites

Officially, you don't have to place spaces after the comment delimiter, however Ingolme is saying that regardless of specification some browsers may not understand properly if there aren't spaces. And yes, apparently you can have a space in between the closing -- and >. Try it out!

Link to comment
Share on other sites

Comments should be able to come before the DOCTYPE[1] (interestingly enough, if you look at the syntax, the DOCTYPE is another type of markup declaration). Are you sure there wasn't a syntax error?

Link to comment
Share on other sites

hmm, that seems like it should work. What text editor do you use? With context it will turn comments green, but it doesn't turn the rest of my code on a test page I made green, so one would assume its OK to do that...

Link to comment
Share on other sites

Big Dave, just remove the comment... why keep it anyway?IE is hard coded to turn on strict mode on only for DTDs and DTDs + xml prolog. It doesn't switch when you have comments in between. Yes, the spec allows it, but IE is quirky in this regard.

Link to comment
Share on other sites

actually, now that boen_robot brings up the IE bug, I had an issue with putting comments in front of the DTD once. Anyway, the DTD in and of itself is the declaration of the start of an HTML document, so it's really the same as saying <!-- ************ HTML Page ************ --> albeit just a bit more technical. And if you must need/want it in there, just put it after the DTD.

Link to comment
Share on other sites

Ya i just removed it. I put it there because I wanted to separate my php code up top from the bulk of my html. Took me awhile to figure out it was the comment. My stylesheet wasnt being interpretted right, nor was any of my JS or JS libraries. What a pain that was!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...