In this article, we will discuss how to add insert both single-line and multi-line comments into your HTML documents. I’ll provide some tips and best practices for using comments effectively in your HTML code.
Commenting out code can be useful in a variety of situations. Like, you might want to temporarily disable a block of code that is causing problems, or you might want to leave notes or reminders for yourself or other developers.
When you add comments to your HTML source code, they will not be displayed in a web browser. This implies that any comments you make will not be visible when the document is rendered in a web browser.
To create comments in HTML, use the symbols. The text you want to comment-out should be enclosed by these symbols.
Be sure to include the exclamation mark at the beginning of the tag. However, there is no need to add it at the end.
A single-line comment is restricted to one line only, and as mentioned before, that line will not be shown in the browser. A single-line comment is beneficial when you want to explain and clarify the purpose of the code.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>How to comment out in html 100 volume</title> </head> <body> <body> <!-- Add the menu here --> <h2>Home</h2> <h2>About me</h2> <h2>Contact US</h2> </body> </html>
You can also use the single-line comments in a long and complex HTML document to notify where the tag ends.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>How to comment out in html 100 volume</title> </head> <body> <!-- start body --> <body> <!-- Add the menu here --> <h2>Home</h2> <h2>About me</h2> <h2>Contact US</h2> </body> <!-- end body --> </html>
You can also add comments in the middle of a sentence or line of code.
However, only the text enclosed by will be commented out, and the remaining text inside the tag will remain unaffected.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>How to comment out in html 100 volume</title> </head> <body> <body> <p>I am <!-- name --> parvez</p> <h2>Home</h2> <h2>About me</h2> <h2>Contact US</h2> </body> </html>
Comments can also span multiple lines, using the exact same syntax you’ve seen so far.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>How to comment out in html 100 volume</title> </head> <body> <body> <h2>Home</h2> <h2>About me</h2> <h2>Contact US</h2> <!-- You can also add multiple menu option here. add social widget--> </body> </html>
You can also comment-out html tag in your html file. You wrap the html tag as like below:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>How to comment out in html 100 volume</title> </head> <body> <body> <!--<p>I am testing comment tag</p>--> <h2>Home</h2> <h2>About me</h2> <h2>Contact US</h2> </body> </html>
I have commented out code in HTML in a variety of ways. This is a simple process that can be very helpful in a variety of situations. Commenting helps to make your code more readable and maintainable. This article will provide you with the knowledge to insert both single-line and multi-line comments into your HTML documents.
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More