Javascript can be included in HTML by embedding it to the HTML file itself or calling an external file.

There are few options to include Javascript code into HTML, but the current best practice is as in the example below;

<script type="text/javascript">
    window.alert("Hello World")

The above example using type and MIME type, when called from anywhere in the HTML page, will pop up an alert with the Hello World text.

Discuss the article:

Comment anonymously. Login not required.