Code highlights logo


HTML comments

HTML comments

HTML comments are a way to add notes and annotations to HTML code without affecting how the web page is displayed in a browser. Comments can be used to provide context, document the code, or temporarily disable a section of code.

HTML comments are created by wrapping the text that you want to comment out in <!-- and --> tags. For example:

1<!-- This is a comment. It will not be displayed in the browser. -->

When to use them

HTML comments are useful for a variety of purposes. They can help make the code more understandable by providing context or explanations for what certain elements do.

For example, you might use comments to explain the purpose of a particular section of code, or to provide instructions for other developers who might be working on the same project.

Comments can also be used to temporarily disable a section of code for testing or debugging purposes. Instead of deleting the code, you can simply comment it out so that it won't be executed.

This can be a useful way to test different versions of a web page without having to rewrite the entire page.



Above our paragraph, let's add a comment that says:

1strong tag is used to bold text

Sign up to start coding

Already have an account?

Sign In

Course content