Comments | HTML | Tutorial 5

Share

Summary

This tutorial explains what comments are in HTML, how to use them, and best practices for writing effective comments. Comments are ignored by browsers and are mainly used for developers to leave notes or temporarily disable code.

Highlights

How to Create HTML Comments
00:00:52

To create an HTML comment, use the syntax: <!-- Your comment here -->. The comment starts with a less than sign, an exclamation point, and two hyphens, and ends with two hyphens and a greater than sign. Any text within these tags will be treated as a comment and will not be rendered by the browser. Comments can span multiple lines.

What are HTML Comments?
00:00:00

HTML comments are pieces of text within HTML code that are ignored by web browsers. Their primary purpose is to provide notes or explanations for developers, either for themselves in the future or for other developers working on the same code.

Using Comments to Comment Out Code
00:02:32

Comments can also be used to temporarily disable specific sections of HTML code. By wrapping HTML elements within comment tags, those elements will be ignored by the browser. This is useful for testing different code snippets or holding content for later use without deleting it.

Best Practices for Using HTML Comments
00:03:41

The speaker advises using comments sparingly. Comments should explain things that cannot be easily understood from the code itself. It's recommended to write clean and readable HTML that 'speaks for itself,' rather than using comments to explain messy or poorly written code. The goal is clarity, and comments should augment clear code, not compensate for unclear code.

Recently Summarized Articles

Loading...