+ 5
This is quite interesting! I didnโt try using comment inside the script tag. I thought it will produce an error. But it didnโt. However, you shouldnโt write using 'html comment style'. Follow the javascript instructions to write a comment.
+ 5
Konika, I totally agree with you and also don't recommend to use it!
+ 4
Konika Actually I guess as <script> tag is part of HTML, the html comment inside this tag, works. Just like when you put a comment inside <div> tag, <p> tag etc. For example :
<div>
<!-- HTML comment and it works -->
</div>
Again,
<script>
<!-- HTML comment and it works too -->
</script>
I think it'll help you clear your doubt!
+ 4
It is not a bad idea. In fact it was the only hack in those days to avoid browsers that don't support javascript from printing all the program in the web page. Since javascript will not raise an error and script-supported browsers will still execute your javascript
But now you don't need that. Just put your script tag in your <head> or place it in an external file if you want to put your <script> tag in <body>
+ 4
Actually the fact that script tag is html code is not the reason for this.
For example try this:
<script>
<!-- lol()
Hello();
-->
</script>
Output: Error Hello is not a function.
<!-- and --> are official SINGLE LINE comments in WEB ECMAScript spec only.
They are part of JS(for compatibility) not of HTML.
--> This is a single line comment.
+ 4
If it's a script tag.
The best thing you should do is add a JavaScript comment
Not an HTML
Coz even if it's internal , you are still gonna write JavaScript in it which is very different from the html syntax
So even if you add an HTML comment it'll be like confusing
And firstly don't use internal js
External is much better
+ 3
This maner is wrong
+ 3
Don't need to give comment inside the script.
+ 3
Yes, you can use it. For example:
<script>
<!-- html comment goes here -->
</script>
+ 2
In script tag we use
// for single line comment
/* used for multiple line comment */
+ 1
If you like i can cake test for you on my account then i send you the link
+ 1
This syntax is wrong forget it please
+ 1
But I used this way for comment
// single line
/* multiple line */
+ 1
You can't use HTML comment inside the script tag.
I suggest that you should try using it then you would notice that the HTML comment won't work inside the script tag
+ 1
people how to make the buttons in this code be like in the mobile version of the browser?
On the mobile, everything is as it should, but on the computer, everything is bad!
https://code.sololearn.com/W17NGHhIZwEX/?ref=app
0
It's impossible
Either you make js comments or html out of the script tag
0
If you make javascript in thoses tag you will look at syntax error
0
What effect do you expect from your tests?
0
When you put some thing in the script tag this thing is supposed to be a script and each script language has his own conment manner so inside the script tag
Forget that you coding in HTML , you have to use the javascript ecpression
For more contact me
0
This beast is from ancient times.
In the dark ages, there were browsers who didn't understand script tags; they're long gone now but the habit remained. What you see is a trick to avoid misinterpretations.
Smart browsers will say:
"OK this is a script tag, let's execute, don't mind the leading <!-- string."
Dumb browsers:
"OK I don't know this tag called script, but inside it's just a comment so I'm gonna skip it. Yep, here's where the comment ends, here's where the weird tag ends, everything's fine."
In 2005 this was important, today it's absolutely not. Your teachers learned this way and pass it on; forget about it, in 2022 literally every toaster and frying pan knows what a script tag is and how to deal with it.