Reputation: 3
I am new to JavaScript, and could use some clarification on the appropriate way to place JavaScript comments within an html file. I have spent time looking this up on the web, but I can only find instructions on how to comment in JavaScript not where to comment. I understand that comments within the script tags are fine (so long as they are not excessive). My question is whether or not it is ok to put JavaScript comments just before the script element. I want to know whether it is syntactically ok, and whether it is acceptable professional practice.
Example:
// Added link to external js for TUT 1 Case 3
<script type="text/javascript" src="../Data Files for Text/Tutorial.01/case3/functions.js"></script>
Is that acceptable, or should I be using html comments outside of the script since this is within an html file? Thanks for any help.
Upvotes: 0
Views: 196
Reputation: 10057
<script>
tag, use script comments.<style>
tag, use style comments.Examples:
<!--
HTML comment
(multi-line)
-->
<script type="text/javascript">
// script comment
/*
script comment
(multi-line)
*/
</script>
<style type="text/css">
/*
style comment
(multi-line)
*/
</style>
Upvotes: 8