HTML: How to Comment With Example
Originally: HTML How to Comment With Example — PHPCODER.TECH
In this article HTML How to Comment we discussed How to comment out in HTML?, HTML comment syntax, and two or more examples where we use HTML comment in the document.
Basically, comments are helpful for web developers or designers to know about source code working which is encapsulated with some information about code using Comment Tag by any developer.
Here are the details which we discuss in this article,
- Major points about HTML Comment Tag
- HTML: How to Comment with Example
- Browser Support
Major points about HTML Comment Tag
- The
<!--...-->
is an HTML Comment Tag. - When you place content or information between
<!--...-->
this tag browser would not show these pieces of information. - Developers can also hide the script tag code using HTML comments.
- Comment out HTML allows developers to leave notes or information about source code.
Also Read: How to Include Comments in CSS
HTML: How to Comment with Example
The HTML comment encapsulate the piece of information by using comment tag.
Syntax
Single Line Comment
<! — This is a comment. Comments are not displayed in the browser →
<p>This is a paragraph.</p>
Multiline Comment
Sometimes we need to comment out multiple lines or some lines of code, then we use multiline comment.
<div>
<p>This text is visible. Check the source code for multi-line comment.</p>
<! —
Hello, world! I am a comment and I am
displayed in multiple lines!
→
</div>
You can also comment out or hide script code which is define inside <script>
tag.
<! — <script type=”text/javascript”>
function displayMsg() {
alert(“Hello World!”)
}
</script> →
OR
<script type=”text/javascript”>
// function displayMsg() {
// alert(“Hello World!”)
// }
</script>
Note: You may also see <comment>
tag somewhere but that comment tag is not supported by modern browsers.
Supported Browsers
Chrome (1+)
Edge (All)
Firefox (1+)
IE (All)
Opera (All)
Safari (All)
Here is the complete explanation HTML Comment.
Also, Read
- Bootstrap Datepicker- Complete Solution to Integrate
- Concept of CSS Grid Layout
- CSS background-image Properties
- Create Date Picker using Materialize Framework
Happy Coding..!