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?
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.
Comments do not nest which means a comment cannot be put inside another comment.
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.
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.
Comments in the XML Spec from the w3.org :
For compatibility, the string "--" (double-hyphen) MUST NOT occur within comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With