Nearby lessons

2 of 40

🛠️ JavaScript Implementation

📌 What is JavaScript Implementation?

JavaScript can be implemented in three different ways in HTML documents. These methods determine where the script runs and how it interacts with the HTML structure. 🤔

  • 📍 Inside the <head> tag
  • 📍 Inside the <body> tag
  • 📂 External JavaScript file

💡 Use the <script> tag to embed or reference JavaScript in HTML. The type="text/javascript" attribute specifies the content type (optional in modern HTML).

📢 The document.write() method writes output directly to the browser. It's often used in simple demos, but not recommended for modern applications.

1️⃣ JavaScript in the <head> tag

Example02
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

2️⃣ JavaScript in the <body> tag

Example03
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

3️⃣ External JavaScript File

Example04
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

💡 Using HTML Tags Inside JavaScript

Example05
Code Cell
Loading Editor...
✏️ You can edit this code — click Run to refresh the preview.
Output

🧠 Test Your Knowledge

5 Questions
Progress: 0 / 5