How can we add comments in HTML code?

WBOY
Release: 2023-08-19 19:29:29
forward
1608 people have browsed it

How can we add comments in HTML code?

In this article we are going to learn about how do we add a comment in HTML code. Let’s dive into the article for getting better understanding on adding comment in HTML code.

To add comments in HTML code, use the comment tag (!—Comment—>). This is good coding practice and allows both coders and readers to benefit from help understanding the code. It is very helpful to understand the steps of complex code. Comment tags are very useful when debugging code.

  • It is a straightforward bit of code that web browsers wipe off (ignore), meaning they do not appear.

  • Understanding the purpose of a piece of code, particularly in complex source code, is helpful to both coders and readers.

Syntax

Following is the syntax for comment in HTML


Copy after login

Let’s consider the following examples to get clear idea on how do we add a comment in HTML code.

Single line comments

Single line comment is given inside the () tag.

Let’s look into the following example

The Chinese translation of

Example

is:

Example

In the following examples we are using the single line comment.




   
   

TutorialsPoint

The Best E-Way Learning

Copy after login

When the script executes, it will generate an output that displays text on the web page without comments.

Multi-line Comment

The syntax (!- ->) can be used to specify several lines. In essence, it is the same as the syntax for single-line comments; the only difference is that the first half of the comment ("- >") is appended when the intended comment line ends.

The Chinese translation of

Example

is:

Example

Considering the following example, where we are using the multi line comment tag.



   
      
      

MSD

The Best Finisher

Copy after login

After running the above script, it will generate output on the web page containing the text used in the script.

Use the tag

An HTML "comment" tag once existed, but none of the current browsers support it.

The Chinese translation of

Example

is:

Example

Look at the example below, we are using the tag.



   
      Heading tag
      

DUCATI

Paragraph tag

The Fastest Bike

Copy after login

When the script gets executed, it will generate an output displaying the text used in the code on the webpage along with the comments used by tag as modern browsers won’t support it.

The above is the detailed content of How can we add comments in HTML code?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!