HTML Comments: Notes in Your Markup
Writing a comment
An HTML comment begins with <!-- and ends with -->. It can document why markup exists. Comments are not rendered as visible page text.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Workshop</title> </head> <body> <!-- Update this heading for each workshop. --> <h1>Drawing workshop</h1> </body></html>Only Drawing workshop appears in the page content. The note remains in the source.
Temporarily hide markup
During editing, you can place a small unused fragment inside a comment. Do not nest comments. Remove unused markup when you no longer need it.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Workshop</title> </head> <body> <h1>Drawing workshop</h1> <!-- <p>Draft schedule</p> --> </body></html>The draft paragraph is not displayed, but anyone inspecting the source can read it.
Common mistake: hiding secrets
Never put passwords, private notes, or API keys in HTML comments sent to a browser. Practice adding a maintenance note above a heading, then inspect the source.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Fundamentals Checkpoint
Check your understanding of document structure, nesting, attributes, and comments.
Which task is HTML primarily responsible for?
Which element normally supplies the browser tab title?
Which markup correctly nests importance inside a paragraph?
Which attribute identifies a single element within a document?
Why should a password not be put inside an HTML comment?