Continue

 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

Here, the given comment is a valid comment and will be wiped off by the browser.

<100CTYPE html>

<html>

<head>

<title>Valid Comment Example</title>

</head>

<body>

<!--This is valid comment -->

<p>Document content goes here.....</p>

</body>

</html>

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>

<head>

<title>Invalid Comment Example</title>

</head>

<body>

<!--This is not a valid comment --> 

<p>Document content goes here.....</p>

</body>

</html>

This will produce the following result:

<1-This is not a valid comment→→

Document content goes here.....






Comments

Popular Posts