Welcome Guest! (App Version 5.16)

websitnero logo name

Adding Script Files to HTML

Overview

  • Scripts can be added either Internally or Externally.
  • Inline scripts can be added using the <script> tags with JavaScript within the tags.
  • External scripts can be added using the <script> tags but rather than adding code within the tags, we add the link to the external script using the src attribute.

Adding Scripts to HTML

There are 2 ways of adding JavaScript to a web page:

The first way is to add <script> tags within the body of the HTML file and add JavaScript code inside it.

<script>
var a = 10;
var b = 20 ;
alert (a + b);
</script>

The second way is to add all the code in an external JavaScript file and then attach this file in the head section of a web page (or at the end of the body section).

<head>
  <script src="someScript.js"></script>
</head>
Further Reading

1. <script>: The Script element

WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.