The <script>
tag is used to define client-side JavaScript. It allows you to add interactive features like alerts, form validations, and dynamic content changes directly into your HTML page.
JavaScript adds logic and interactivity to a website. The <script>
tag either includes JavaScript code directly or references an external JavaScript file.
<script> // JavaScript code here </script> OR <script src="script.js"></script>
<!DOCTYPE html> <html> <head> <title>Script Example</title> <script> function greet() { alert("Welcome to the website!"); } </script> </head> <body onload="greet()"> <h1>Hello User</h1> </body> </html>
The <script>
tag is essential for adding dynamic and interactive features to your web pages using JavaScript. It can be used inline or to load scripts from external files.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!