Where should I put script tags in HTML markup?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
How To Add JavaScript to HTML
You can add JavaScript code in an HTML document by employing the dedicated HTML tag
<script>
that wraps around JavaScript code.The
<script>
tag can be placed in the<head>
section of your HTML or in the<body>
section, depending on when you want the JavaScript to load.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.You can add JavaScript code in an HTML document by employing the dedicated HTML tag
<script>
that wraps around JavaScript code.The
<script>
tag can be placed in the<head>
section of your HTML, in the<body>
section, or after the</body>
close tag, depending on when you want the JavaScript to load.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.However, if your script needs to run at a certain point within a page’s layout — like when using
document.write
to generate content — you should put it at the point where it should be called, usually within the<body>
section.The JavaScript code should be inserted between <script> and </script> tags in HTML. You can place the <script> tags, containing your JavaScript, anywhere within your web page, but it is normally recommended that you should keep it within the <head> tags.