
Apu
February 09, 2023 ›
#Javascript
›
#Q&A
❌
Which of the following is the correct place to insert JavaScript in HTML?
- A) <script> tags
- B) <body> tags
- C) <head> tags
- D) <style> tags
Answer: A) <script> tags.
Explanation: The correct place to insert a JavaScript in HTML is within the <script> tag. The code between the script tags will be executed by the browser when the HTML page loads.
Example:
<script> console.log("Hello World!"); </script>
save
listen
AI Answer
Which of the following is the correct place to insert JavaScript in HTML?
1
A) <script> tags B) <body> tags C) <head> tags D) <style> tags Answer…
asked
Apu
1 answers
2915
A) <script> tags B) <body> tags C) <head> tags D) <style> tags Answer…
Answer Link
answered
Apu
Generally, JavaScript code can go inside of the document <head> section in order to keep them contained and out of the main content of your HTML document.
<html>
<head>
<script>
console.log("Hello World!");
</script>
</head>
<body>
<p>This is a paragraph.</p>
</body>
</html>