New course! Every coder should learn Generative AI!
Try a free lesson0
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 ?
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 ;)