The comment tag (
<!--...-->) is used to add a note to an HTML document that is meant for developers only. Users do not see comments.
A comment that is not visible to users.
<!-- A note that documents the code -->
<!--...--> tag treats all its content as HTML comment.
Comments are used to add developer notes that describe the code.
Comments are ignored by the browser and are not shown to the users.
The comment is not visible, but the paragraph is.
This paragraph is visible to users.
<!-- This comment is not be visible to users. --> <p>This paragraph is visible to users.</p>
Note: Comments are not shown to the users, but they do exist in the page source.
Therefore, never include sensitive information, such as passwords, in your comments.
Comments are often used to temporarily 'hide' a block of code, until it is revisited at some later point.
In developer speak this is called 'commenting out the code'.
This example demonstrates this practice.
Notice that three text fields are hidden by the browser.
<form action="/tutorial/action.html"> <input type="text" name="firstname" placeholder="First name"> <br /><br /> <input type="text" name="lastname" placeholder="Last name"> <br /><br /> <!-- TODO: review the need for these fields <input type="text" name="email" placeholder="Email"> <br /> <input type="text" name="city" placeholder="City"> <br /> <input type="text" name="country" placeholder="Country"> <br /> --> <button type="submit">Submit</button> </form>
When comment support started for each browser: