HTML Comment
Multiline Comments
Multiline Comments
You have seen how to comment a single line in HTML. You can comment multiple lines by the special beginning tag <!–- and ending tag -–> placed before the first line and end of the lastline to be treated as a comment.
Example
<!DOCTYPE html>
<html>
<body>
<!--
This is a multiline comment <br>
and can span through as many as lines you like.
-->
<p>The above content is commented so you cant see it
in output</p>
</body>
</html>
HTML Document Output
The above content is commented so you cant see it in output
Valid vs Invalid Comments
Valid vs Invalid Comments
Comments do not nest which means a comment cannot be put inside another comment. Second the double-dash sequence "--" may not appear inside a comment except as part of the closing --> tag. You must also make sure that there are no spaces in the start-of comment string.
Example
<!DOCTYPE html>
<html>
<body>
<!--This is valid comment -->
<p>Document content goes here.....<p>
</body>
</html>
HTML Document Output
Document content goes here.....
But, following line is not a valid comment and will be displayed by the browser. This is because there is a space between the left angle bracket and the exclamation mark.
<!DOCTYPE html>
<html>
<body>
< !--This is valid comment -->
<p>Document content goes here.....<p>
</body>
</html>
HTML Document Output
Document content goes here.....

0 Reviews:
Post a Comment
If you have any doubts, Let me know, Please!