Commenting in html

Tell us what’s happening:
hey,am trying comment element h2 and element p that that should not be visible on the page,but it have failed.how can i do it?

Your code so far


<!-- should not be visible on the page-->
<h1>Hello World</H1>

<h2>CatPhotoApp</h2>
<!-- should not be visible on the page -->
<p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0.

Challenge: Comment out HTML

Link to the challenge:
https://www.freecodecamp.org/learn/responsive-web-design/basic-html-and-html5/comment-out-html

the should not visible text is in fact not visible

but it seems you need to make not visible something else

remember that the comment starts <!-- and ends with -->

1 Like

I completely agree with @ilenia ’ s answer.

Let’s try to show off an example of how an HTML comment tag works:

If I’ll like to create a <span> tag, I’d probably write down something like this:

<span> This is a span tag </span>

Then, if I’d like to write down a comment line, I’d probably do so by typing:

<!--- This is a comment line -->

Computers, while reading programming languages, are designed to ignore whatever it’s inside the comment clausules (that means, whatever is between <!--- and ---> for the HTML language).

But, what happens if I want to comment something more than just a line? What if I want to comment 3 lines, for example? Well, that could be accomplished the same way:

<!---
This line has been commented
This line has also been commented
Oh, wait: there are more lines been commented! Wow!
--->

Now, what if I want to comment some code that I just wrote?

Well, as we explained before, it turns out, computers will ignore everything’s that fits inside the comment clausules, so we can have our previous <span> tags commented as well:

The following <span> tag:

<span> This is a span tag </span>

Can be commented like this:

<!--- This is the begining of a comment line
<span> This is a span tag </span>
This is the end of a comment line -->

This way, my span tag has been ignored by the computer, thus, not showing it off in the webpage.

Now go out and try to solve your excersive, which may include some of the concepts that has been explained here, or the combination of more than just one concept.

Best of luck and happy coding! :+1:

1 Like