Is it necessary to create script tag in html to show alert box? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it necessary to create script tag in html to show alert box?

Can't we just make js file, code there and show alert box in html without using script tag ?

3rd Jun 2021, 3:33 AM
Harsh
Harsh - avatar
1 Answer
+ 1
no: to execute a js script (either in external file or embeded in script tag), you must include it in an html page... however, as html is a very permissive language, you could simply start your js file with an opening script tag and end it with a closing one (and save it with '.html' extension): browsers would make the minimal html code for empty page... this will not be a valid html file, but should work as you expect ;)
3rd Jun 2021, 3:40 AM
visph
visph - avatar