0

What would happen if we use <script> within the <head> and <body> tags?

Normally it's used only within either of the two. Can you run separate JavaScript codes from two different tags?

6th Aug 2018, 12:42 PM
Akhila Seneviratne
Akhila Seneviratne - avatar
2 Réponses
+ 1
If you include <script> tag within <head> tags, your javascript file will be included and compiled before touching html code. If you include <script> within body or as a best practice, in the end of <body> all the HTML code will be parsed first and then Javascript will be compiled and linked to HTML tags. However, using <script> inside <head> or <body> is based on the type of programme or the functionalities you want to achieve.
6th Aug 2018, 2:05 PM
Velan
Velan - avatar
0
Thanks!
6th Aug 2018, 2:32 PM
Akhila Seneviratne
Akhila Seneviratne - avatar