What\'s the difference between HEAD tags and BODY tags?
most HTML books only \'briefly\' mentions and
tags...but they
tags are run when the browser encounters them when loading the page. The
can't contain content for the page, it can only contain meta-information (titles, descriptions, etc), styles and scripts. Therefore if you place a
tag in the
, you are ensuring that it is run before the browser has started loading the content of the page (which must go in the
).
If you want to manipulate the content of the page, you need to make sure your script appears after the content you are manipulating. This is why people chose to put scripts at the end of the .
If your code is sloppy (for example, with tags not closed properly), this can cause problems. This is why libraries like jQuery have features to help you run code manipulating the document at the right time.