HTML comments | Intro to HTML/CSS: Making webpages | Computer Programming | Khan Academy

– 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, 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 we do in all sorts of programing languages because we often want to do things that are just for humans. That’s the thing about programs, there 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. O.K., 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. If they want to update it. I’ll say this paragraph is based on the Wikipedia article… I should probably give a
link to that too, but.. And this paragraph is based on Pamela’s personal opinion. It’s a very well trusted source, and then, you know, maybe we’d even say give a link inside the comments. 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 part of our HTML. Like if we want to experiment with taking something away from our webpage, we just surround it with a comment. Dah, dah, dah. 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 like 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 web page code, which is pretty much all of us now, right?

Author: Kevin Mason

Leave a Reply

Your email address will not be published. Required fields are marked *