Home > Back-end >  What is the difference between the <!-- text --> and /* text */ comments?
What is the difference between the <!-- text --> and /* text */ comments?

Time:12-19

What is the difference between the and /* text */ comments? Are they both the same thing or is there a difference in function?

CodePudding user response:

Yes, they're almost the same thing. However, we use <!--text--> in HTML and use /*text*/ in CSS, JavaScript and many others.

CodePudding user response:

/* comments are used in C like languages.

<!-- comments are used in html / xml like languages.

If the language you are considering uses one or both, as long as the language recognizes it as a comment, there's probably not a difference.

The only reason to choose one or the other when designing a language is to for consistency within the language or to avoid syntax constructs that would be better used for something else.

CodePudding user response:

Same thing just depends on the language you are writing code in. Use a code editor like VS code to automatically write comments in whatever detected language by a simple shortcut instead of memorizing.

  • Related