CourseHTML Comments
Core Concept
100% Comprehensive
HTML Comments.
Comments are notes in your code that are not displayed in the browser. they are used to explain parts of the code to yourself or other developers.
The Essentials
01
The syntax is <!-- comment goes here -->.
02
Comments can span multiple lines.
03
They are great for 'commenting out' code during debugging.
04
Browsers completely ignore comments when rendering the page.
05
They are only visible when someone views the 'Source Code'.
06
Use them to mark the start and end of large sections.
Professional Insights
Developer Documentation
In large teams, comments are used to explain why a certain structure was chosen, making it easier for others to maintain the code later.
Debugging with Comments
Instead of deleting code you might need later, wrap it in comment tags. This is called 'commenting out' and is a core developer workflow.
Security Note
Never put sensitive information (like passwords or private URLs) in HTML comments. Anyone can see them by right-clicking and choosing 'View Page Source'.
Clean Code
While useful, too many comments can make your file size larger and your code harder to read. Use them only for complex or non-obvious sections.
Critical Pitfalls
Trying to nest comments (e.g., <!-- <!-- --> -->)—this will break the comment.
Putting a comment inside a tag (e.g., <h1 <!-- --> >).
Using // or /* */ as comments—those are for JavaScript and CSS, not HTML.
Forgetting the closing -->, which will hide the rest of your entire page!
Interactive Lab
Sprint Tasks
01
Add a comment above the heading that says 'Main Title'02
Comment out the paragraph so it disappears from the previewLoading editor...
Production Preview