DONATE  
MENU
JSON
HTML
AJAX
CSS
JAVASCRIPT
MYSQL
PHP

HTML Tutorials

INTRODUCTION

» Introduction to HTML

» PRACTICE IT Editor

» Getting Started

» HTML Example

» HTML Tags

» HTML Elements

» Nesting Tags

» Block & Inline Elements

» HTML Attributes

» HTML Comments

» File Paths

» HTML Entities & Symbols

TAGS/ELEMENTS

» Important Tags

» HTML Headings

» Text Formatting

» HTML Links

» HTML Lists

» HTML Tables

» HTML Images

» HTML Audios

» HTML Videos

» HTML Iframes

» HTML Styles

» HTML Scripts

» Semantic Elements

» HTML Metadata

ATTRIBUTES

» Elements' ID

» Elements' Class

» Elements' Style

» Element's Align

» Element's Height & Width

HTML FORMS

» HTML Forms

» Input Elements

» HTML Textarea

» HTML Select

HTML EXAMPLE

» Login Page

.. » HTML » Tags/elements » HTML Scripts
Share Tweet WhatsApp

HTML Scripts

The HTML <script> tag is used in defining JavaScript programs in a webpage. It can be used in bringing just any JavaScript script on the internet into a webpage. This can be achieved by specifying the path to the JavaScript file as the value to the src attribute of the <script> element. EXAMPLE
<script src='myjavascript.js'></script>
The <script> tag can also be used in defining JavaScript programs directly on a webpage without using any third party scripts. Nevertheless, such programs can only be applied on the webpage where they were declared. EXAMPLE
<!DOCTYPE html>
<html>
<head>
<title>
Script Example
</title>
</head>
<body>
<div id='placeholder'></div>
</body>
<script>
window.addEventListener("load",writeText);

function writeText(){
document.getElementById("placeholder").innerHTML = "<h1>Hello World</h1>";
}
</script>
</html>

Copy PRACTICE IT

You can have as many script elements as you want. This means, you can bring as much script files as you want and write as much programs as you want on a webpage using the <script> tag but everything must be in accordance with JavaScript tenets.
NOTE:
  • You will or can learn more about JavaScript files and programs on the separate JavaScript tutorials.
SUMMARY
  1. You can add JavaScript to a webpage using the <script> tag.
  2. This may be by bringing external JavaScript files.
  3. Or directly writing JavaScript programs usable on a webpage on that same webpage.
  4. You can have as many script elements as you want in a webpage.
  5. You can learn about JavaScript here in the JavaScript tutorials but you should understand HTML basics first.
Take a short quiz on HTML Scripts.
Ask a question or tell us if HTML Scripts is easy or not.
cent?

Join our 1,090 subscribers to receive tutorials' updates!

  We won't spam your mail box. We hate it.





StackBeginner 2021 © Joseph Omamode