- Used to define JavaScript within the document
- Can contain script statements, or
- Can refer to an external script file via the src attribute
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<!DOCTYPE html> <html> <head> <title>My Document Title</title> <script> document.write("Hello, World!"); </script> <script src="/js/myJavaScript.js"></script> </head> <body> </body> </html> |
Save & refresh browser:
Hello, World! |
*note: if defining an external src file the script element must be empty.