-
Everything that we've put
in our webpages so far
-
has been either
content displayed by the browser,
-
or tags to tell the browser
how to display it.
-
Sometimes though, we just want to put
information in our webpages
-
for other humans to read,
and for the browser to ignore.
-
To do that, we write
an opening angle-bracket,
-
an exclamation mark,
two dashes,
-
and some text inside here,
-
and then two dashes
and a closing angle-bracket.
-
We call this a comment.
-
And it's something that we do
in all sorts of programming languages,
-
because we often want to do things
that are just for humans.
-
That's the thing about programs:
-
they're not just
for computers to look at,
-
they're also for
other humans to look at.
-
Because we often work together
on things and learn from each other.
-
Okay, what do we use comments for,
-
besides just saying "hello"
to our fellow humans?
-
Well, we might use them for
letting people know
-
where content came from,
in case they want to update it.
-
I'll say, "This paragraph is based on
the Wikipedia article,"
-
and I should probably
give a link to that, too, but...
-
And, "This paragraph is based on
Pamela's personal opinion,"
-
a very well trusted source.
-
Then maybe we'd even, say,
give a link inside the comments,
-
and say, "These lyrics were from here."
-
And that helps people know
how I got the content of this page.
-
Do you notice something
about these comments?
-
They are all green.
-
That's because we're using a code editor
with syntax highlighting,
-
and it uses colors to help us
see what's what,
-
and comments are pretty much
always colored green, by convention.
-
We could also use comments to
"comment out" parts of our HTML.
-
Like if we want to experiment with
taking something away from our webpage.
-
We just surround it with a comment.
-
♪ (humming) ♪
-
Now, the browser
no longer sees that HTML,
-
because browsers ignore
everything in comments,
-
and that part is gone from the page.
-
If I decide that I actually liked it,
I can comment it back in
-
by removing those comments
on both sides...
-
and now it's back!
-
Remember, comments are for humans.
-
At least, the kind of humans that
like to look at webpage code.
-
Which is pretty much
all of us now, right?