TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

HTML

HTML Comments

Overview

The HTML comments tag is used to add a comment to the HTML code. The web browser ignores the comment. We can use the comment tags to explain the HTML code, program documentation, author information, license header, etc.

The text in the HTML comment tag will not be displayed on the web page. Comments are meant for others to understand the code better. Comments increase code readability.

HTML Comments Syntax

<!– HTML comment here –>

Comments start with <!– tag and end with –>

Example

<html>

<body>

<h1> Hi, How are you?</h1>
<br>
<!– Sample HTML comment –>
<!– This two lines are not displayed on the browser –>

<h2>Welcome to www.TestingDocs.com</h2>

</body>

</html>

HTML Editor generally highlights the comments in different color text.

HTML Comments

Lines 7, 8 are comments in the code. The comments are single-line comments. They start with <!– tag and end with –> tag.

Sample Output

HTML Comments Output

 

Multiline Comments

Comments can span across multiple lines. Example of multi-line comment shown below:

<!– Sample HTML comment
Example of Multi-Line long HTML
Comment.
–>

We can even decorate the comment tag with extra characters. For example, to display a box-like comment box.

<!–
####################################
# Program Author:
# Date :
# Display greeting to user.
#
# Revision History: Initial Draft.
#
# Review Comments:
#
####################################
–>

Common Error

The most common error is using spaces in the comment tags. For example,

< !–

This is an invalid HTML comment. There is a space in the comment start tag between angle bracket and exclamation mark.

–>

Invalid comments will be displayed in the browser.

—

HTML Tutorials

HTML Tutorials on this website:

https://www.testingdocs.com/html-tutorials/

More Information on HTML:

https://www.w3.org/TR/html401/intro/intro.html

Related Posts

Create HTML File

HTML /

Create HTML file with NetBeans IDE

HTML /

HTML5 Document Structure

HTML /

Introduction To HTML5

HTML5 Application NetBeans

HTML /

Create an HTML5 Application using NetBeans IDE

CSS Validator Tool

HTML /

HTML & CSS Validator Tools

‹ Introduction to HTML› HTML Elements

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle
  • Draw Parallel Lines using Flowgorithm Graphics

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version