Javatpoint Logo
Javatpoint Logo

HTML Multiline Comment

The Comment Tag in HTML

An HTML comment should generally be written like this:

Remember to include the exclamation point at the beginning of the tag! However, you can omit adding it at the end.

The tag surrounds any text or HTML tag you wish to remark out.

When to Use Comments in HTML

  • The browser does not show HTML comments. This implies that when the page is produced in a web browser, any comments you make to your HTML source code will not be shown.
  • Remember that virtually any website put online may have its source code viewed by anybody by going to View -> Developer -> View Source; this even applies to comments! Therefore, their comments will be available if you want to publicize the HTML content and someone else decides to look at the source code.
  • Following best practices and writing comments is a good idea when developing source code. By using comments, you may better document and communicate to yourself (and others) about your code and thought process. Returning to a project after months of non-working reminds you of your thoughts and actions.

Moreover, comments facilitate communication between you and the other developers working on the project. They can easily understand why you inserted specific lines of code from your comments.

How to Write HTML Single-Line Comments

A single-line remark is limited to one line in length. As previously stated, the browser will not display that line.

When you wish to add self-reminders or elaborate on the reasoning for the code that comes after it, use a single-line remark like this:

You may also use single-line comments to indicate the end of a tag. This is helpful when you have lengthy, intricate HTML text with plenty of information and might not know where to put the ending tag.

How to Write HTML Inline Comments

Comments can also be added during a statement or a line of code.

The remaining content within the tag will remain unaffected; just the text included in <!-- --> will be commented out.

How to Write Multi-Line Comments in HTML

Using the same syntax as before, comments may also span many lines.

How to In HTML Comment Out a Tag

What if you want to remove a tag from an HTML document?

You encircle the chosen tag in <!-- --> as follows:

Taking tags out of comments facilitates debugging.

Start commenting out specific tags one at a time if anything isn't functioning as it should or as you had expected. This enables you to test them and identify the problematic ones.

Shortcut on the Keyboard for Adding HTML Comments

You may make comments using shortcuts and likely find yourself utilizing them frequently. For Mac users, the shortcut is Command /; for Windows and Linux users, it is Control /.

HTML

CSS

You can use this for single line comments:

You can also use it for multi-line comments:

You can also insert the comment anywhere you want if it is not within a tag:







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA




news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news
news