TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

HTML Comments

HTML Comments with html tutorial, tags, anchor, img, div, entity, textarea, marquee, p tag, heading tag, h1, h2, table, formatting, attribute, elements, ol, ul, Input Types, block element tag, inline element tag, html tags, phrase tag, head, body, form, lists, symbols etc.

<< Back to HTML

HTML Comments

Comments are some text or code written in your code to give an explanation about the code, and not visible to the user. Comments which are used for HTML file are known as HTML comments. Anything written between these tags will be ignored by the browser, so comments will not be visible on the webpage.

Comments of any code make code easy to understand and increase readability of code.

Comments are also part of the code, which gives an explanation of the code.

How to add comment In HTML

You can add comments in your HTML file using <! -- ... --> tag. So if you will write anything between theses comment tag that will be treated as comment and browser will not read it.

Syntax

<! -- Write commented text here -->

Note: The commented code will not be visible to a webpage, and hence you can use comment tag for documentation purpose, and debugging purpose:

Such as:

<!--   <p>There is some text</p>
  	   <p>There is second text</p> -->

Example:

<!DOCTYPE html>
<html>
<!-- This is Header section -->
<head>
	<!-- Internal CSS -->
	<style>
		body{
			text-align: center;
			background-color: #f0f8ff;
			font-size: 30px;
			color: red;
		}
	</style>
</head>

<!-- This is body section, write code here which you want to display on web-page -->
<body>
	<!-- heading tag -->
 <h2>First WebPage</h2>

 <!-- Paragraph tag -->
 <p>Write your Content here!!!</p>
</body>
</html>
Test it Now

Multiline Comment

In HTML code, we can also comments multiple lines at a time. In multiline comment we can use any description about code or multiple line code to debug, etc.

Syntax

<!---
Your code is commented. 
Write description of code.
It will not display at webpage. 
-->

Example:

  <h2>Cake Gallery</h2>
	<!-- This is image for a yummy cake
 you can see it on your web-page
 of your favorite browser -->
 <img src="/tutorial/htmlpages/images/cake.png" alt="cake image" height="300px"
  width="300px">
Test it Now

Output:

HTML Comments

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<!-- -->YesYesYesYesYes
Next TopicHTML File Paths




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf