Friday, September 22, 2023

HTML Comments

                             HTML Comments

HTML comments are not displayed in the browser, but they can help document your HTML source code.

HTML Comment Tag

You can add comments to your HTML source by using the following syntax:

<!-- Write your comments here -->

The exclamatory mark is in the begining and it is not at the end.

Note: Comments are not displayed by the browser, but they can help document your HTML source code.

Add Comments

With comments you can place notifications and reminders in your HTML code:

Example

<!DOCTYPE html>
<html>
<body>

<!-- This is a comment -->
<p>This is a paragraph.</p>
<!-- Comments are not displayed in the browser -->

</body>
</html>

Note: comments are not diplayed in the browser

Hide Content

Comments can be used to hide content.

This can be helpful if you hide content temporarily:

Example

<!DOCTYPE html>
<html>
<body>

<!-- This is a comment -->
<p>This is a paragraph.</p>
<!-- Comments are not displayed in the browser -->
<!--This is another paragraph-->
<p>Hii</p>

</body>
</html>

Hide Inline Content

Comments can be used to hide parts in the middle of the HTML code.

Example

Hide a part of a paragraph:

<!DOCTYPE html>
<html>
<body>
<!--hiding content inside a paragraph-->
<p>This <!-- great text --> is a paragraph.</p>
<p>Hii</p>

</body>
</html>

No comments:

Post a Comment

Building Static Website(part6) HTML Lists

  Building Static Website (part6) HTML Lists Today, let us add some lists to our detailed view section by using html lists. Lists: List is a...