JavaScript Tutorial

The language for programming web pages.

JS Where To

Where to Put JavaScript?

JavaScript can be placed in the <head> section, in the <body> section, or in an external file.

3 Ways to Include JavaScript:

  1. Inline JS — inside an HTML element attribute
  2. Internal JS — inside a <script> tag in the HTML file
  3. External JS — in a separate .js file linked with <script src="">

Best Practice: Use external JS files to keep code organized and reusable.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics