Single and multiline comment in HTML, CSS and JavaScript

How to give a single and multiline comment in HTML, CSS and JavaScript?

Last updated:7/20/2021 1:33:06 AM

1 Answers

Ethan Karla
Ethan Karla

Adding comments to your code is a helpful way to include notes that explain to you or others what the code does. Code or other text that is commented out is ignored by the browser.

How to write comments in HTML

Single line HTML comments

To comment out a single line of HTML, place the text or code you are commenting between comment tags: <!-- -->.

Multiline HTML comments

To create a multiline or block HTML comment, you still use the comment (<!-- -->) tags, but you can have more than one line in your comment. As long as you contain the comment text between the tags, it will be included in the comment.

How to write comments in CSS

Single line CSS comments

To make a single line CSS comment, put the comment text or code between /* */tags.

Multiline CSS comments

To write multiline or block CSS comments, you can use the same /* */ tags, and put the comment content on multiple lines.

How to write comments in JavaScript

Single line JavaScript comments

To create a single line comment in JavaScript, begin the line with two forward slashes (//).

Multiline JavaScript comments

If you want to create a multiline or block comment in JavaScript, enclose the comment text between /* */ tags. (This is the same method as in CSS.)

Answer