JavaScript

JavaScript – Put JavaScript inside Body Tag

JavaScript inside Body Tag

JavaScript code can be placed inside the <body> and </body> tag of the HTML document.

Using JavaScript code in the body section will be better for the loading of the web page or HTML document.

We can put JavaScript code in the <head> section also but that will take more time to load the webpage.

Most of the time JavaScript code can be placed before the closing of the </body> section.

HTML / JS Code

<html>
<head>
</head>
<body>
<script language="javascript" type="text/javascript">
document.write("Hello World!!");
</script>
<p> This is saying hello world. So I say hello to the world. Please accept my hello.</p>
</body>
</html>

Output

This is saying hello world. So I say hello to the world. Please accept my hello.

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

javascript
JavaScript

JavaScript – Introduction, History, and Syntax

  • September 17, 2020
What is “JavaScript”? The first appearance of JavaScript was made in Netscape 2.0 in 1995 with a name Live Script.
javascript
JavaScript

JavaScript – Write Program to Print Hello World!!!

  • September 17, 2020
JavaScript is scripting language which is similar to C. It is syntax and logic are similar to C, C++ and