HTML <!- -…- -> Tag
In this article, we will be discussing about HTML Tag comment. Trying to meet the learning needs with this content.
An HTML comment:
Example
Here is another example of the comment with code written inside it:
Example: 
Uses and Definition
In the source code, comments are inserted using the tag comment. Browsers do not display comments.
Can use Comments to clarify your code, which can be helpful when editing the source code later. Coders with a lot of code will particularly benefit from this.
By using the comment tag, you can “hide” scripts from browsers without script support (so they won’t appear as simple text) in tag comment:
<!–
function displayMsg()
{
alert(“This is Alert Document”)
}
//–>
</script>
Browser Compatibility
Element | |||||
---|---|---|---|---|---|
<!–…–> | Yes | Yes | Yes | Yes | Yes |
Event Attributes
There are no event attributes accepted in the tag comment.
Here are more details about Event Attributes.
Standard Attributes
There are no standard attributes included in the tag comment.
Here is more information about Standard Attributes.
Advantages of using HTML Tag Comment
HTML tag comments have several advantages, including:
- Comments help developers to organize their code and make it easier to read and understand. By including comments, you can explain their code to other developers or remind themselves of what the code does.
- When code isn’t working as expected, comments can be used to isolate the problem. You can comment out code to see if it’s causing the issue, or add comments to identify where the issue may be occurring.
- When multiple developers are working on a project, comments can help them communicate and coordinate their efforts. Comments can provide context for code changes, explain why certain decisions were made, or highlight areas that need further work.
- Comments can be used to create documentation for a project. By including comments that explain how code works or how to use certain functions, you can make it easier for others to work with their code.
- Comments can help with code maintenance by making it easier to update or modify code. By including comments that explain how code works, you can quickly understand what changes need to be made and why.