Java script in web page

in my html code even after adding the javascript file its not showing after opening it.I did exactly as it was mentioned in the course but I don’t know what is wrong

no need to add file .
In your html file , you can add the content of the java script file in the tag script and closing it by /script

example: In the html file inside the body tag you can add this

java script content

note: this is when the 1st way is not working(the one by which its done in the video). and wherever i wrote script and /script it should start and end with the angular brackets.

Hope it works now!


Please make sure that you are importing the JS file correctly with relevant path.
Ideally while developing the project, keep the js file in the same folder where the html file is present and use it directly.
Also, make sure you have not misspelled the filename in the code.

Can you share the HTML code so that we could debug the same and resolve your issue?

You can write in the script tag also for example

It’s just an example only I’m giving to you. I have tired many examples and formed many html pages using javascript and CSS.
Or you can make another file with .js extension and copy the whole path of that file and paste it in

As I have given full path of the file, because sometime html file and js file is not in same folder so, error occurs so you can give full path so that your code may run.
I used tomcat server to run my html codes, you can also use that, it will be helpful to you in future.
I hope you got the answer.

Then, you have to check your js file path??
and consider the js path in your html file.
I hope this will be helpfull.

From the code that you have shared, the js file having name “my-javascript.js” must be present in the same folder as that of your html page.

If it still doesn’t work, please share the entire html as well as js code. The code that you have shared is incomplete, the first 10 lines are not visible.

can you please explain how to create a java script in sublime and execute it on web page

Hi @krithikyadavmanka,

You can write your html code in any editor (Sublime, Notepad, Notepad ++ etc ) . After writing the code, save it with .html extension . For example : mypage.html

Then go to the icon of file where you have saved it and right-click on the file -> Open with -> Chrome/Firefox etc.

  1. So you will write code in editor (Sublime. notepad etc)
  2. and can view the output in browser (Chrome, Safari, Firefox)

Do let me know in case you need further assistance.

Actually I don’t know how to write the code