- 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>
Comments (1)
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>