Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML comments break down

Tags:

I have a page that is generated which inserts an HTML comment near the top of the page. Inside the comment is a *nix-style command.

<!-- command --option value --option2 value2 --option3 --> 

This comment breaks the page completely. What is wrong with the comment to cause this to happen, and why is this the case?

like image 889
Rudd Zwolinski Avatar asked Aug 07 '08 22:08

Rudd Zwolinski


People also ask

How are comments delimited in HTML?

To include comments in an HTML document that will be ignored by the parser, surround them with <! -- and -->. After the comment delimiter, all text up to the next occurrence of -- is ignored. Hence comments cannot be nested.

Can HTML comments be nested?

Comments do not nest which means a comment cannot be put inside another comment.

What are HTML comments explain?

HTML <!--...--> Tag The comment tag is used to insert comments in the source code. Comments are not displayed in the browsers. You can use comments to explain your code, which can help you when you edit the source code at a later date. This is especially useful if you have a lot of code.

How do you comment multiple lines in HTML?

You can create a single line comment by putting <! -- at the start and --> at the end of your comment. You can also make a multi-line comment in HTML by adding <! -- at the beginning of your comment and --> at the end of your multi-line comment.


1 Answers

Comments in the XML Spec from the w3.org :

For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.

like image 138
McDowell Avatar answered Sep 22 '22 15:09

McDowell