Welcome Guest! (App Version 3.1)

websitnero logo name

Adding Script Files to HTML

Overview

  • Scripts can be added by only 2 ways -- rather than 3 like CSS.
  • Inline scripts can be added using <script> tags.
  • External scripts can be added still using script tags but adding source of file by src attribute.
  • Earlier there were 2 options -- "vbscript" and "javascript", but now only 1 survived so all front-end script is written in javascript only.

Adding Scripts to HTML

There are 2 ways of adding JavaScript to a web page or HTML file.

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

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

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

<script src ="someScript.js"></script>

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.