Comments in HTML

Comments in HTML is used to block or close code that we don’t want to execute in browser. It is mean that user could be able to see this comments, only able to see in the source code.

Comments in HTML normally written in source code by opening tag with an exclamation point (!) and closing tag with by –> without (!).

<!-- Statement -->

We can use this comments in HTML source code with cover one statement or many statements depend on your code that you want to NOT execute.

Example

<!DOCTYPE html>
<html>
<head>
  <title>HTML Quotation and Citation Elements</title>
</head>
<body>
  <h1>Examples of Quotation and Citation Elements</h1>

  <h2>Blockquote </h2>
  <blockquote cite="https://www.freecode4learn.com">
    <p>This is a long quote from Freecode4learn.com.</p>
  </blockquote>

  <h2>Inline Quote </h2>
  <p>My website: <q cite="https://www.freecode4learn.com">This is an inline quote.</q></p>
  <h2>Citation </h2>
  <p><cite>Free Code 4 Learn</cite> is website for programming.</p>

  <h2>Abbreviation </h2>
  <p>The <abbr title="This is my site">FCL</abbr> which created for learning. </p>
  <h2>Address </h2>
  <!--
  <address>
    Written by <a href="mailto:info@freecode4learn.com">Sambth</a>.<br> 
    Visit us at:<br>
    freecode4learn.com<br>
    Cabrammatta, Sydney<br>
    Australia
  </address>
-->
  <h2>Definition </h2>
  <p><dfn>HTML</dfn> stands for HyperText Markup Language.</p>
</body>
</html>

The example above is show that comments in HTML is only readable in HTML source code, not display in browser. However, if you want to view this comments, you can view by right click on your browser and click on view source,

freecode4learn.com

Leave a Reply