Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

The Shape of an HTML Document · Lesson 10 of 18

Comments in HTML

A free lesson from Swipe Coding · HTML, level 1 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

HTML comments let you leave notes in your code that browsers completely ignore when rendering the page. They start with <!-- and end with -->, and anything in between is invisible to visitors.

<!-- This is the site navigation -->
<nav>
  <a href="/">Home</a>
</nav>
The comment explains the section below it, but never appears on the page itself.
🤖
Comments are for future-you, and for anyone else reading your code later. 📝

Comments are useful for labeling sections of a longer page ('this is the header,' 'this is the footer'), leaving reminders about something that needs fixing later, or temporarily disabling a piece of HTML without deleting it while testing.

One thing worth knowing: HTML comments are not truly hidden. Anyone can view a page's source code and read every comment in it. Never put anything sensitive — passwords, private notes, internal-only information — inside an HTML comment.

Quick check

How does an HTML comment begin and end?

Fill in the blank

Content inside an HTML comment is invisible on the rendered page, but anyone can still see it by viewing the page ____.

True or false

It is safe to put a password or private note inside an HTML comment, since browsers never display it.

Chapter quiz

The Shape of an HTML Document

10 questions · pass with 60% — just like in the app.

Quick check

What is the correct HTML5 doctype declaration?

<!DOCTYPE html>
True or false

The doctype declaration should be placed at the very top of an HTML file, before anything else.

Fill in the blank

The ____ element holds everything a visitor actually sees on the page — text, images, buttons, and links.

Quick check

What are the two direct children of the <html> element?

True or false

A single tag can only ever have one attribute.

Fill in the blank

A(n) ____ is a tag together with everything inside it, from the opening tag to the closing tag.

Quick check

Which of these is a self-closing (void) element that never needs a closing tag?

True or false

<p>Some <strong>text</p></strong> is correctly nested HTML.

Quick check

How does an HTML comment begin and end?

True or false

It is safe to put a password or private note inside an HTML comment, since browsers never display it.

Keep your streak going in Swipe Coding

Swipe through every level of HTML on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →