HTML and CSS · lesson 9 of 30 · free

HTML comments — HTML and CSS for kids

A comment is a note in your code for people, not for the browser. HTML comments start with a bracket, an exclamation mark and two dashes, and end with two dashes and a bracket. The browser does not show anything inside a comment, so coders use comments to explain their code or to switch a line off for a while. Anyone can still read comments by viewing the page source, so never put passwords in them.

▶ Watch how it works

Got it? Practise ↓

Code tip

Hidden notes — “anything inside a comment is not shown on the page”

  1. A comment is <!-- note -->: it starts with <!-- and ends with -->.
  2. Anything inside a comment, even a whole <p>, is not shown.
  3. Comments can be read with “view source” — never put secrets in them.

Use it for: Leaving notes in your code, hiding a line while testing, and reading other people’s code.

Worked example: 💬 How many paragraphs show on the page?
<!-- <p>Cricket is fun.</p> -->
<p>Our school trip</p>
<p>Fun facts</p>
<!-- <p>My best friend</p> --> → 2

  1. 4 paragraphs are written, but 2 are inside <!-- -->.
  2. 4 − 2 = 2 paragraphs show.

Check: Only “Our school trip” and “Fun facts” show ✓

▶ Watch it animated

✏️ Practice

Work it out in your head or on paper, type the answer and press Check. Stuck? Press “Show me how”.

Right: 0 · Tried: 0

🏁 Lesson 9 test

20 questions. Check each answer, then go to the next one. Get 16 or more right to pass.

🏅 Sign in with Google to earn the 💬 Comment Whisperer badge when you pass — and a certificate when you finish all 10 lessons of Part 1 · HTML Basics. You can still take the test without signing in.

🖨️ HTML Worksheet: Comments

✨ Free AI tutor

Ask the AI tutor about this lesson

Why does it work? When should you use it? Ask in English, मराठी or हिंदी.

Sign in with Google to ask Free — 20 questions a day.

👩‍🏫 HTML and CSS classes near you — online or at home

Prefer a real teacher? TalentJR teachers take live online classes anywhere in India and visit homes in selected cities. Tell us what you need and our team will call you with timings and fees.

Live online classesSmall groups or 1:1 with a teacher, from home, any city.
Teacher at homeA TalentJR teacher visits your home (selected cities).
At a centreClasses at a TalentJR partner centre near you, where available.
Badges, certificates & gifts A badge for every lesson you pass, a certificate for every part you finish, plus TalentJR Points for daily practice. Computer worksheets Flowcharts, block coding, spreadsheets and safe internet.