comments

G:hackHTMLmyHTML-Tutorial�4- comments�1.png

You can add comments in in your page. We use comments to add comments to the source code. These comments are not shown in browsers and are only used for developers to explain what a line of code or portion of a code does.

This is not mandatory but is very helpful to add comments to your code and explain what each portion of code does so that later on when you return to the source code, you can read these comments and figure out the structure of codes and what the code does.

The structure of comment is:

Open bracket followed by exclamation point followed by 2 dashes (so far NO SPACES ALLOWED) followed by comments (can add space here) followed by 2 dashes followed by close bracket (no spaces is allowed between dashes and close bracket)

< ! – comment — >

Example:

<!DOCTYPE html>
<html>
<head>
<!-- We use title tag to set the title of a page -->
<title>this is the title of this page</title>
</head>
<!-- comment -->
<body >
<!-- p tag stands for paragraph -->
<p>Hello World</p>
</body>
</html>

As long as you follow the structure of the comment, there’s no difference between:

<!—comment -->

And

<!—

Comment

–>