Download script outside html document

I went through this html fragment, and to my surprise, a jQuery object is being created!

<!doctype html> <body> <h1>Hello World</h1> </body> </html> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script> 

As you can see, the <script> appears after closing the </html> . I wonder how and why it works?

+7
source share
3 answers

This works because browsers are very forgiving, there is no use for it.

The reason this happens is probably because someone misunderstood what was meant by "installing scripts as far as possible on the page" ...

+4
source

If you check the file, it will say that it is not valid. However, browsers usually try and do what you probably had in mind.

Browsers are not so strict. You can make many mistakes, and they will still work.

+3
source

I checked this code for firefox, the script is considered as a body body tag for this particular case.

Browsers are really error resistant.

+1
source

All Articles