How to Write Comments in HTML

Table of contents:

How to Write Comments in HTML
How to Write Comments in HTML

Video: How to Write Comments in HTML

Video: How to Write Comments in HTML
Video: How to delete only "recently closed tabs" in Chrome? (4 Solutions!!) 2024, December
Anonim

By commenting the code, you can leave reminder messages and explanations for yourself as well as other code writers who will be working on the HTML page. The comments feature can also be used to quickly disable a piece of code when you're testing or working on a new feature that isn't ready. By learning how to use comments well, both you and your coworkers can write code more efficiently.

Step

795094 1
795094 1

Step 1. Enter a single line comment

Comments are enclosed by and. You can include a short comment to remind what is going on in the code you are working on.

  Comment testing  

This is a site

Make sure there are no spaces in the comments. For example, < !-- will not activate the comment function. Within the area enclosed by the mark, you can add as many spaces as you want

795094 2
795094 2

Step 2. Create a multiline comment

Comments can be lined up so that they are useful for explaining complex code or disabling large sections of code.

  Comment testing   Comments can be written as long as you want. Any posts in the uncomment will not affect the code on the page.

This is a site

795094 3
795094 3

Step 3. Use the comment function to quickly deactivate the code

If you're trying to find an error or want to prevent code from running on a page, you can use the comment function to quickly disable code. That way, you can revert the code by uncommenting it.

  Comment testing  

Check the following pictures

Hide pictures for now

795094 4
795094 4

Step 4. Use the comment function to hide the script in browsers that don't support a certain code

If you're writing a program in JavaScript or VBScript, you can use the comment function to hide the script in browsers that don't support running it. Enter a comment at the beginning of the script, and end it with // to ensure that the script works in supported browsers.

  VBScript    

// at the end of the sign will prevent the script from executing the comment function if the script is supported by the browser you are using

Recommended: