HTML TutorialLesson #12

HTML Comments

HTML comments are not displayed in the browser, but they can

HTML comments are not displayed in the browser, but they can help document your HTML source code.


HTML Comment Tag

You can add comments to your HTML source by using the following syntax:

Example

Example Code

html
Try it Yourself
<!-- Write your comments here -->

Notice that there is an exclamation point (!) in the start tag, but not in the end tag.

Note: Comments are not displayed by the browser, but they can help document your HTML source code.


Add Comments

With comments you can place notifications and reminders in your HTML code:

Example

Example Code

html
Try it Yourself
Live Output Preview:

Hide Content

Comments can be used to hide content.

This can be helpful if you hide content temporarily:

Example

Example Code

html
Try it Yourself
Live Output Preview:

You can also hide more than one line. Everything between the <!-- and the --> will be hidden from the display.

Example

Example Code

html
Try it Yourself
Live Output Preview:

Comments are also great for debugging HTML, because you can comment out HTML lines of code, one at a time, to search for errors.


Hide Inline Content

Comments can be used to hide parts in the middle of the HTML code.

Example

Example Code

html
Try it Yourself
Live Output Preview:

Video: HTML Comments


Interactive Code Examples

Example 1

html
Try it Yourself
HTML tag syntax and structure demonstration.
<!-- Write your comments here -->

HTML Example 2

html
Try it Yourself
Interactive runnable HTML example from EA Academy.
Live Output Preview:

HTML Example 3

html
Try it Yourself
Interactive runnable HTML example from EA Academy.
Live Output Preview:

HTML Example 4

html
Try it Yourself
Interactive runnable HTML example from EA Academy.
Live Output Preview:

HTML Example 5

html
Try it Yourself
Interactive runnable HTML example from EA Academy.
Live Output Preview: