Add comments to HTML (with images)

Table of contents:

Add comments to HTML (with images)
Add comments to HTML (with images)

Inserting comments into your code allows you to post descriptions and explain code to yourself and other programmers who will be working on the page. Comment tags can also be used to quickly disable certain parts of your code during testing, or when working on new features that have not yet been finalized. By learning how to post comment tags properly, you can program more efficiently, which is useful for both yourself and your colleagues.


795094 1

Step 1. Enter comments on one line

'Comments' are determined by the tags and. You can enter short comment tags to help you remember what certain code does.

  Comment test   <!-This code creates a paragraph

This is the website

Make sure there are no spaces between the comment tags. For example < !-- will not activate the comment function. You can add as many spaces as you want within the tags

795094 2

Step 2. Post comments in multiple lines

Your comments can be spread over several lines, which is useful for explaining complex code, or for blocking large chunks of code.

  Comment test   Your comment can be as long as necessary. Anything within the comment tags will not be executed and thus will have no effect on the page.

This is the website

795094 3

Step 3. Use the comment function to quickly disable code

If you want to debug the code, or if you don't want code to run on the page, you can use the comment function to quickly block code. That way, by removing the comment tags, it's also easy to recover code.

  Comment test  

View these images

This image will now be hidden first

795094 4

Step 4. Use the comment feature to hide scripts on unsupported browsers

If you're programming in JavaScript or VBScript, you can use the comment function to hide the script in browsers that don't support it. Add the comment to the beginning of the script, then end it with // to make sure the script works on browsers that support it.


Popular by topic