JavaScript is used in HTML to change behaviour of elements like it can change the content of html elements, it can call functions to perform different actions etc. JavaScript is inserted in two ways within HTML page.
External js is inserted in HTML page by using <script> element. The benifit of using external js is it separate HTML code form js code and makes code easy to understand and you can apply same js file to multiple pages.
<script src=js file
></script>
You can insert any number of js files using script element.
You can give any name to js file but do not forget to give .js
extension after js file name
Internal js is inserted in HTML page by using <script> element, if your web page has different functions or you have wanrt to apply funtions to single page then internal js is good.
<script>
js code
</script>
You can use any number of js files using script element.
You can give any name to js file but don’t forget to give .js
extension after js file name
Don't forget that you can use multiple js files in a single HTML page.
Open notepad or any other text editor, follow the following points.
myid
save file with name task.html or task.htm and then open it using any browser and see results.
You can use javascript any where within HTML page.