HTML Tutorials


» Introduction to HTML


» Getting Started

» HTML Example

» HTML Tags

» HTML Elements

» Nesting Tags

» Block & Inline Elements

» HTML Attributes

» HTML Comments

» File Paths

» HTML Entities & Symbols


» Important Tags

» HTML Headings

» Text Formatting

» HTML Links

» HTML Lists

» HTML Tables

» HTML Images

» HTML Audios

» HTML Videos

» HTML Iframes

» HTML Styles

» HTML Scripts

» Semantic Elements

» HTML Metadata


» Elements' ID

» Elements' Class

» Elements' Style

» Element's Align

» Element's Height & Width


» HTML Forms

» Input Elements

» HTML Textarea

» HTML Select


» Login Page

.. » HTML » Introduction » HTML Comments
Share Tweet WhatsApp

HTML Comments

HTML comments allow us to write whatever we don't want a browser to interpret or consider on a webpage. With the help of HTML comments, we can therefore write some information about the origin and content of a webpage so that whoever comes across our HTML markups or source code can understand such origins and how the content were put together. The idea of HTML comments is to make the source code of a webpage readable either by us and whoever may come across such web documents maybe for maintenance purposes. Syntax We can create a comment in HTML by,
<!-- Your comment goes here -->
Comments can only be seen in the HTML markups or source codes but not in the interpretation of the web content as browsers ignore them, With HTML Comments
<div id='holder'></div>

<!-- The div is empty because it will be populated via a JavaScript function. -->


With the above, whoever comes across our document source will be able to know why that <div> element is empty. Without HTML Comments
<div id='holder'></div>

The div is empty because it will be populated via a JavaScript function.


Above, you have written a comment but then, it will be shown when the webpage is interpreted because you didn't follow the proper syntax for defining comments. SUMMARY
  1. HTML comments allows us write texts or whatever that the browser should ignore when interpreting our webpage.
  2. This helps us write down our thoughts when creating a webpage. For example, writing down how complex aspects of our webpage were put together.
  3. This helps us and other web developers to understand our webpage source code at just any time.
  4. An HTML comment is started with <!--, followed by whatever comment and finally, -->.
  5. We can also comment out a part of a webpage, we no longer want to display instead of arbitrarily deleting it.
Take a short quiz on HTML Comments.
Ask a question or tell us if HTML Comments is easy or not.

Join our 1,090 subscribers to receive tutorials' updates!

  We won't spam your mail box. We hate it.

StackBeginner 2021 © Joseph Omamode