Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why are there two ways to comment code in HTML and which way to use?

I am new to HTML. I’m learning HTML from this YouTube video. When I’m going to comment code in VS Code (using Command + /), this is by no means the way to show comments taught in the YouTube video, but a different way Ways to annotate code.

Sample code:

<!DOCTYPE html>
<html>
  <body>
    <h1>My First Heading</h1>

    <p>My first paragraph.</p>
  </body>
</html>

When using Command + / in VS Code, the result is as follows:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

{% comment %} <!DOCTYPE html>
<html>
  <body>
    <h1>My First Heading</h1>

    <p>My first paragraph.</p>
  </body>
</html> {% endcomment %}

When using the way taught in this YouTube video, the results are as follows:

<!--
<!DOCTYPE html>
<html>
  <body>
    <h1>My First Heading</h1>

    <p>My first paragraph.</p>
  </body>
</html>
-->

Why are there two ways to comment code in HTML and which way to use? I would appreciate any help. Thank you in advance!

>Solution :

The HTML comment is <!-- your comment -->. You should use this one.

{% comment %} seems like a framework template. If you save your file to HTML, this syntax appears in your documents.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading