Learn one of the most powerful programming languages in the world and become a rockstar developer.
The script element is used to embed or reference JavaScript within an HTML document to add interactivity or affect the behavior of web pages.
The <script>
element is used to define a client-side script.
The script in the example below writes Hello World! to the HTML output:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Embedded JavaScript Example</title> </head> <body> <script> document.write("Hello World!"); </script> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>External JavaScript Example</title> </head> <body> <script src="hello.js"></script> </body> </html>