This lesson finishes the HTML basics with two handy tools: tags for quoting what someone said, and comments for leaving notes to yourself inside your code.
flag
What you'll learn
How to show a short quote inside a sentence.
How to show a longer quote as its own block.
How to leave notes in your code that visitors never see.
waving_handLet's quote and take notes
News stories quote people all the time. HTML has a tag for a short quote inside a sentence, and another for a longer quote that stands on its own.
It also lets you write comments: notes in your code that the browser skips completely.
sticky_note_2
Think of an editor working on a news draft. The story includes what people said, some of it short and some long.
The editor also sticks notes on the draft, like "add a photo here". Those notes help the team, but they're peeled off before the story is printed, so readers never see them.
In HTML, those sticky notes are comments.
<!-- TODO: add a photo of the new office -->
<h2>Our New Office Opens Monday</h2>
<p>
The editor said <q>we're adding more tech news</q>.
</p>
<blockquote>
Our goal is simple: make tech news easy for everyone to read.
</blockquote>
<!-- Ask Ana to double-check this quote -->
<p>
Everyone is welcome to visit.
</p>
Now let's see the tags and notes ↓
<!-- TODO: add a photo of the new office -->
<h2>Our New Office Opens Monday</h2>
<p>
The editor said <q>we're adding more tech news</q>.
</p>
<blockquote>
Our goal is simple: make tech news easy for everyone to read.
</blockquote>
<!-- Ask Ana to double-check this quote -->
<p>
Everyone is welcome to visit.
</p>
Readers only ever see the first version. The yellow sticky notes are comments: they stay in your code for you and your team, and the browser never shows them.
searchA closer look
Short quote or long quote
<q> is for a short quote inside a sentence. The browser adds the quote marks for you, so don't type your own.
<blockquote> is for a longer quote. It sits on its own lines and is pushed in from the left, so it stands apart from your own words.
How comments work
A comment starts with <!-- and ends with -->. Everything between them is skipped by the browser, even across several lines.
People use comments to leave to-do notes, to label the parts of a long page, and to hide a piece of code for a while without deleting it. That last one is called commenting out.
Hidden, but not secret
Visitors don't see comments on the page, but anyone can read them by right-clicking a page and choosing View Page Source. So never put passwords or private information in a comment.
constructionLet's build it
Let's write an announcement for Front Page Bytes. Each step shows the whole page, and the new lines are highlighted.
1Step 1: A short quote
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Our New Office Opens Monday</h2> <p>The editor said <q>we're adding more tech news</q>.</p> </body></html>
What you see
description(no title)
<q> wraps what the editor said, right in the middle of the sentence. Look at the mini browser: the quote marks appear even though we didn't type any.
2Step 2: A long quote
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Our New Office Opens Monday</h2> <p>The editor said <q>we're adding more tech news</q>.</p> <blockquote>Our goal is simple: make tech news easy for everyone to read.</blockquote> <p>— The Front Page Bytes team</p> </body></html>
What you see
description(no title)
<blockquote> shows the team's full statement as its own block, pushed in from the left. The paragraph below says who said it.
3Step 3: Leave a note for yourself
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <!-- TODO: add a photo of the new office --> <h2>Our New Office Opens Monday</h2> <p>The editor said <q>we're adding more tech news</q>.</p> <blockquote>Our goal is simple: make tech news easy for everyone to read.</blockquote> <p>— The Front Page Bytes team</p> </body></html>
What you see
description(no title)
The new line is a comment: a reminder to add a photo later. Compare the mini browser with step 2. Nothing changed, because the browser skips comments.
4Step 4: Hide a line without deleting it
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <!-- TODO: add a photo of the new office --> <h2>Our New Office Opens Monday</h2> <p>The editor said <q>we're adding more tech news</q>.</p> <blockquote>Our goal is simple: make tech news easy for everyone to read.</blockquote> <p>— The Front Page Bytes team</p> <!-- <p>Free coffee for every visitor!</p> --> <p>Everyone is welcome to visit.</p> </body></html>
What you see
description(no title)
The free-coffee paragraph is wrapped in a comment, so it doesn't appear on the page. To bring it back later, just remove <!-- and -->.
sticky_note_2Quick notes
<q>Short quote inside a sentence
He said <q>hello</q>.
How to use
Wrap a short quote inside a sentence.
The browser adds the quote marks for you.
Examples
A short quote from a person.
<p>The mayor said <q>Classes resume on Monday.</q></p>
A short quote inside a story.
<p>Fans called it <q>the best phone this year</q>.</p>
<blockquote>Long quote on its own
<blockquote>A longer statement.</blockquote>
How to use
Wrap a long quote. It gets its own indented block.
Put <p> tags inside it for quotes with several paragraphs.
Examples
A long statement in a news story.
<blockquote> <p>We worked on this phone for two years.</p></blockquote>
A long quote with two paragraphs.
<blockquote> <p>First part of the quote.</p> <p>Second part of the quote.</p></blockquote>
<!-- -->Comment: a note the browser skips
<!-- TODO: add a photo -->
How to use
<!--Starts the note.
-->Ends the note. Without it, the rest of the page is hidden.
Comments can go anywhere in your HTML.
Examples
A reminder for yourself.
<!-- TODO: add a photo -->
A label for a part of the page.
<!-- Weather section --><h2>Weather Today</h2>
<!-- <p>…</p> -->Hiding code for a while
<!-- <p>Old text</p> -->
How to use
Wrap the code you want to switch off for now.
Remove <!-- and --> to bring it back.
Examples
Hide an old paragraph for now.
<!-- <p>Old text</p> -->
Hide a picture while you test the page.
<!-- <img src="banner.jpg" alt="Banner"> -->
reportCommon mistakes
These are mistakes many beginners make. Each mini browser shows what really happens.
error
Typing your own quote marks inside <q>
The mistake
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <p>The editor said <q>"we're adding more tech news"</q>.</p> </body></html>
What you see
description(no title)
<q> already adds quote marks, so typing your own gives you two sets.
tips_and_updatesTip: Let <q> add the marks: <q>we're adding more tech news</q>
error
Forgetting to close a comment
The mistake
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Our New Office Opens Monday</h2> <!-- TODO: add a photo <p>The office is on the 3rd floor.</p> <p>Everyone is welcome to visit.</p> </body></html>
What you see
description(no title)
Without -->, the browser thinks the comment never ends. Everything after <!-- disappears, including the two paragraphs.
tips_and_updatesTip: Every comment needs both ends: <!-- your note -->