How to Make a Single Line and Multi-line Comment in HTML
Table of Contents
In this post, we will learn how to make single line and multi-line comments in HTML.
Comments in HTML
You can make comments in HTML by using the <!--
and -->
tags. Everything between these tags is ignored by the browser.
You have to use these tags for both making single line and multi-line comments. Let's look at examples of how to make single line comments and multi-line comments in HTML.
Single line comments
This is an example of a single-line HTML comment:
HTML<!-- This is a comment -->
Multi-line comments
This is an example of a multi-line HTML comment:
HTML<!--
This is a multi-line comment.
It can span multiple lines.
And it can even contain HTML!
<p>
This is a paragraph inside a multi-line comment.
</p>
-->
Conclusion
You can use comments to explain the HTML markup you've written to yourself. You can also use comments to make your markup easier to read and understand by labeling different sections.
Another use for comments is to hide parts of a website from rendering, like things that are still in development or to quickly disable certain functionality.
Either way, hopefully this post has helped you learn how to make single line and multi-line comments in HTML.
- Git Tutorial: Learn how to use Version Control
- How to Serve Static Files with Nginx and Docker
- How to Set Up Cron Jobs in Linux
- Best Visual Studio Code Extensions for 2022
- How to deploy a PHP app using Docker
- How to deploy a Deno app using Docker
- Build a Real-Time Chat App with Node, Express, and Socket.io
- Getting User Location using JavaScript's Geolocation API
- Getting Started with Moment.js
- Using Push.js to Display Web Browser Notifications
- Building a Real-Time Note-Taking App with Vue and Firebase
- Setting Up a Local Web Server using Node.js