HTML Comments
Hey friends 👋 welcome back, Today, we are going to learn about HTML comments, which allow you to add notes in your code that do not show up in the browser, Comments are very useful for explaining your code, leaving reminders, or temporarily hiding parts of your HTML.
Creating a Comment
You can create a comment in HTML using <!-- to start and --> to end, Example:
-
Anything between
<!--and-->will not appear on the web page
Using Comments Effectively
Comments can be used for:
1, Explaining sections of your code
2, Temporarily disabling code
3, Leaving reminders for yourself or team members
Best Practices
-
Keep comments short and meaningful
-
Use comments to explain why, not just what
-
Avoid over-commenting, too many comments can make the code messy
Practice Time
Create a file called comments.html and try these exercises, 1, Add a comment at the top of your HTML file with your name and date, 2, Comment out a paragraph so it does not display in the browser, 3, Add a reminder comment for adding an image later, 4, Add a comment explaining your heading
Great job, You just learned how to use comments in HTML to make your code easier to understand and manage, In the next lesson, we will explore HTML Headings and Paragraphs, where we will learn how to structure text on a web page, We will soon be launching our YouTube channel, where we are going to post step-by-step video tutorials on HTML and other web skills, These videos will make learning easier and more visual, helping beginners follow along confidently.
0 Comments