• Send Us A Tip
  • Calling all Tech Writers
  • Advertise
Monday, June 22, 2026
  • Login
TechStory
  • News
  • Crypto
  • Gadgets
  • Memes
  • Gaming
  • Cars
  • AI
  • Startups
  • Markets
  • How to
No Result
View All Result
  • News
  • Crypto
  • Gadgets
  • Memes
  • Gaming
  • Cars
  • AI
  • Startups
  • Markets
  • How to
No Result
View All Result
TechStory
No Result
View All Result
Home How to

How to write JavaScript in HTML

by Arya Roy
June 24, 2021
in How to, Tech
Reading Time: 3 mins read
0
How to write JavaScript in HTML

Source: https://www.hackreactor.com/blog/what-is-javascript-used-for/

TwitterWhatsappLinkedin

JavaScript, also referred to as JS, is one of the client-side scripting languages that is usually used in web development to create modern and interactive web pages. The term “script” is used to refer to languages that are not inherently standalone in nature. In this case, it refers to the fact that JavaScript runs on the client machine.

You might also like

How to cancel a 24 Hour Fitness Membership?

How to transfer an e-SIM to a new phone?

How to freeze your credit for free?

In other words, it can also be said that the term “scripting” is used for languages that need the support of another language to get executed. For example, JavaScript programs will not get executed without the help of HTML or if they are integrated into an HTML code.

JavaScript is used in a wide range of ways when it comes to web pages, such as build image galleries, generating warning messages, manipulation of DOM, form validation, etc.

Users can easily add JavaScript to HTML pages using an embedding code. In order to add JavaScript code into the HTML pages, use the <script>…..</script> tag of the HTML that gets wrapped around JavaScript code while inside the HTML program.

Users can also define JavaScript code in either the <body> tag – also known as body tag – or <head> tag owing to the fact that it entirely depends on the structure of the web page that the users decide to use.

This can be understood more clearly with the help of an example of adding JavaScript to HTML, as shown below.

Input: 

<!DOCTYPE html >

<html>

<head>

<title> page title</title>

<script>

document.write(“Welcome to Javatpoint”);

</script>

</head>

<body>

<p>Inthis example we saw how to add JavaScript in the head section </p>

</body>

</html>

Output: 

Source: https://www.javatpoint.com/how-to-add-javascript-to-html

As mentioned above, you can also define the JavaScript code in the <body> tags or body section.

Input:

<!DOCTYPE html >

<html>

<head>

<title> page title</title>

</head>

<body>

<script>

document.write(“Welcome to Javatpoint”);

</script>

<p> In this example we saw how to add  JavaScript in the body section </p>

</body>

</html>

Output:

Source: https://www.javatpoint.com/how-to-add-javascript-to-html
Tags: HTMLJavaScript
Tweet55SendShare15
Previous Post

Embark Trucks goes Public!

Next Post

Cheapest Space Flight offered by Space Perspective at $125K per person

Arya Roy

Hi, this is Arya! Writing has always been a passion of mine, regardless of the topic I choose. Besides that, I am a huge foodie and music lover, whose interests range from world politics to horror films to everything in between.

Recommended For You

How to cancel a 24 Hour Fitness Membership?

by Afeefa Ansari
June 22, 2026
0
24 Hour Fitness

Want to take a break from the gym? It's alright, we've got you. Follow the guide to know how you can cancel the 24 Hour fitness membership and...

Read more

How to transfer an e-SIM to a new phone?

by Afeefa Ansari
June 22, 2026
0
ESIM

Do you have an e-SIM you want to transfer to a new phone? Here is how you can do that! Follow the guide to know how you can...

Read more

How to freeze your credit for free?

by Afeefa Ansari
June 22, 2026
0
Freeze credit

Do you want to freeze your credit for free? Here is how you can do it in no time at all! It is a simple process that lets...

Read more
Next Post
Cheapest Space Flight offered by Space Perspective at $125K per person

Cheapest Space Flight offered by Space Perspective at $125K per person

Please login to join discussion

Techstory

Tech and Business News from around the world. Follow along for latest in the world of Tech, AI, Crypto, EVs, Business Personalities and more.
reach us at info@techstory.in

Advertise With Us

Reach out at - info@techstory.in

Aviator Game India 2026

BROWSE BY TAG

#Crypto #howto 2024 acquisition AI amazon Apple Artificial Intelligence bitcoin Business China cryptocurrency e-commerce electric vehicles Elon Musk Ethereum facebook funding Gaming Google India Instagram Investment ios iPhone IPO Market Markets Meta Microsoft News OpenAI samsung Social Media SpaceX startup startups tech technology Tesla TikTok trend trending twitter US

© 2025 Techstory.in

No Result
View All Result
  • News
  • Crypto
  • Gadgets
  • Memes
  • Gaming
  • Cars
  • AI
  • Startups
  • Markets
  • How to

© 2025 Techstory.in

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?