Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
56 views
in General by (65.1k points)
closed by

Introduction to Script Tag.

1 Answer

+1 vote
by (68.9k points)
selected by
 
Best answer

JavaScript can be implemented using script... /script tags. The script tag containing JavaScript can be placed anywhere within the web page, but it is normally recommended that it should be kept within the head tags. The script tag alerts the browser program to start interpreting all the text between these tags as script commands. 

The syntax of a JavaScript segment in Hyper Text Markup Language (HTML) is as follows: 

JavaScript Program

The SCRIPT tag takes two important attributes: 

1. Language-This attribute specifies the scripting language. Typically, its value will be JavaScript. The recent versions of HTML have phased out the use of this attribute and have become optional.

2. Type- This attribute is used to indicate the scripting language and its value should be set to 'text JavaScript'. All current browsers are updated and JavaScript enabled by default. This attribute too is optional. 

There are three different places in the HTML document where scripts can be used: 

1. Body of the page: In this case when page is loaded in the browser then output is displayed as the part of the HTML document.

2. Header of the page: In this case code is written in the form of a function (groups of JavaScript statements but treated as a single unit and referred to in the other script in the same page). 

3. As external file: In this case JavaScript code is written in another file having js extension. This file is included in a script tag by specifying the file name.

Writing first JavaScript program 

JavaScript program

Output on the browser: hello World! 

1. Open any editor such as notepad and write the above program. 

2. Save the program with the html extension in a proper folder or subfolder. 

3. Open the web browser like Google Chrome. 

4. Double Click the file you have created and saved in step 2, and then you can the output of your program.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...