JavaScript location in HTML File
There is flexibility in providing JavaScript code anywhere in an HTML document. However, the most preferred ways to include JavaScript in an HTML file are:
- Script in the area .
- Script in the area .
- Script in the area . and .
- Script in the peripheral file and then include in the area .
In the next section, we will see how we can put JavaScript in an HTML file in different ways:
JavaScript in the area .
If you want to have a script run on some event, such as when the user enters somewhere, then you will put that script in the Head as follows: