Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

HTML script tag

HTML script tag with examples, forms, input, text, anchor, image, heading, marquee, textarea, paragraph, title, quotes, code etc.

<< Back to HTML

HTML Script Tag

HTML script tag is used to specify client-side script such as JavaScript. It facilitate you to place a script within your HTML document.

JavaScript is used for image manipulation, form validation, and dynamic content.

The syntax of script tag is given below:

  //code to be executed

Attributes of HTML script tag

srcIt specifies the URL of an external script file.HTML 4.01, HTML5
typeIt specifies the media type of the script.HTML 4.01
asyncIt is a boolean value which specifies that the script is executed asynchronously.HTML5
deferIt is a boolean value which is used to indicate that script is executed after document has been parsed.HTML 4.01, HTML5

Usage of script tag

There can be two usage of HTML script tag:

  1. to embed script code
  2. to link script file

Embed script code

The script tag can be used within <body> or <head> tag to embed the scripting code. Let's see the example to have script tag within HTML body.

<script type="text/javascript">
document.write("JavaScript is a simple language for TheDeveloperBlog learners")
Test it Now


JavaScript is a simple language for TheDeveloperBlog learners

Let's see the example to have script tag within HTML head tag.

<script type="text/javascript">  
function msg(){  
 alert("Hello TheDeveloperBlog");  
Test it Now

Link script file

The script tag can be used to link external script file by src attribute. It must be used within the <head> tag only.

<script type="text/javascript" src="message.js" />
Click me to see full example

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
Next TopicHTML section tag

Related Links:

Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf