

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Should I write my script in the body or the head of the HTML?
It is suggested that you should place the script within the <head> tag or <body> tag. It is good for performance to add JavaScript in <body> element.
Example
Here is an example to add <script> under <body>…</body> −
<html> <body> <script> <!-- document.write("Hello World!") //--> </script> </body> </html>
- Related Questions & Answers
- Should I always put my JavaScript file in the head tag of my HTML file?
- Should I include language="javascript" in my SCRIPT tags?
- Should I include type=“text/javascript” in my SCRIPT tags?
- What are the three types of errors I can expect in my JavaScript script?
- Being a girl, where should I get a Tattoo done on my body and why?
- How should I manage my life?
- Where should I put <script> tags in HTML markup?
- Should I name the username field in my MySQL table “name” or “user_name”?
- I sweat a lot even in Winters. How to maintain the moisture and salt content of my body?
- Why should Muslim women cover their face or body?
- My girlfriend never appreciates me, what should I do?
- Execute a script when the length of the media changes in HTML?
- How do I check what version of Python is running my script?
- Which one should I use? The datetime or timestamp data type in MySQL?
- Execute a script when the user opens or closes the <details> element in HTML?
Advertisements