Hi students,
In this section, we will cover the importance of adding comments in your HTML code.
One of the most important aspects of documenting software is writing comments on your code. Comments are lines that exist in computer programs that are ignored by interpreters and compilers, and are intended to be read by humans.
Writing comments allows you to make your code more readable and explain what specific parts of a program are doing. For example, if you’re writing a long program, you may use comments to keep track of certain functions or lines of code.
Comments in HTML documents are enclosed within special arrows and are separate from the rest of the program. Comments are not displayed by the browser. Here is the syntax for a basic HTML comment tag:
<!--- This is a comment --->
Notice that there is an exclamation point (!) in the start tag, but not in the end tag.
With comments:
You can place notifications and reminders in your HTML code.
You can use them to help debug HTML code, because you can comment out HTML lines of code, one at a time, to search for errors.
The syntax for multi-line comments is the same as single-line comments, with the only difference being that the comment closes on a new line. Here’s the syntax for a multi-line comment tag:
<!---
This is a multi-line comment
that appears on multiple lines
because it is long.
--->
Comments should generally be used:
To describe the intended outcome of code.
To explain why code has been written.
To clarify a complex line or lines of code.
Commentaires